-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathExceptionHandling
More file actions
34 lines (25 loc) · 981 Bytes
/
Copy pathExceptionHandling
File metadata and controls
34 lines (25 loc) · 981 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
Exception Handling :
differnce between classNotFoundException and noClassDefError(similar to noBeanDefinationException in spring.)
try
catch
finally
checked excption
unchecked excpetion
custom exception special catogery.
can be created in 2 ways
-- extending Exception Class -- for checked while complie time.
Public class InsufficientFundException extends Exception{
public InsufficientFundException(String message){
super(message);
}
}
-- extending RuntimeException Class -- for runtime No need to check at run time.
Public class InvalidAccountException extends RuntimeException{
public InvalidAccountException(String message){
super(message);
}
}
gloabl exception
in spring we use a special case were @ControllerAdvice and @ExceptionHandler
here @ControlerAdvice is a class level excpetion.
@ExceptionHandler in is a method level exception. (it can also accomidate multiple classes at the same time to handle.)