Custom Exception Example
package com.anshul.aih.projects.iwts.tests;
public class MyCustomException extends Exception{
String status;
MyCustomException(String status) {
this.status=status;
}
public String toString(){
return ("Exception thrown as status is "+status) ;
}
}
package com.anshul.aih.projects.iwts.tests;
public class MyCustomExceptionDemo {
public static void main(String args[]){
String status;
status = "Inactive";
if (status.equalsIgnoreCase("ACTIVE")){
System.out.println("Active");
}
else if (status.equalsIgnoreCase("INACTIVE")){
System.out.println("Inactive");
try {
throw new MyCustomException(status);
} catch (MyCustomException e) {
e.printStackTrace();
}
}
else {
System.out.println("OK");
}
}
}
Subscribe to:
Post Comments (Atom)
SpringBoot Application Event Listeners
When a spring boot application starts few events occurs in below order ApplicationStartingEvent ApplicationEnvironmentPreparedEvent Applicat...
-
1. Create a tld file inside WEB-INF folder having declaration of the custom function as below <?xml version="1.0" encoding=...
-
Issue : When trying to execute "maven clean install", I am getting an error message saying "PKIX path building failed. unable...
No comments:
Post a Comment