[text] exception

Viewer

copydownloadembedprintName: exception
  1. /**
  2.  * 
  3.  */
  4.  
  5. import org.springframework.http.HttpStatus;
  6.  
  7. import lombok.Data;
  8. import lombok.EqualsAndHashCode;
  9.  
  10. /**
  11.  * Global custom checked exception
  12.  * 
  13.  * @author karthik
  14.  *
  15.  */
  16. @Data
  17. @EqualsAndHashCode(callSuper = false)
  18. public class WebappException extends Exception {
  19.  
  20.         /**
  21.          * 
  22.          */
  23.         private static final long serialVersionUID = -446084203675831053L;
  24.  
  25.         private HttpStatus status;
  26.  
  27.         private String message;
  28.  
  29.         private transient Object details;
  30.  
  31.         public WebappException(Exception e) {
  32.                 super(e);
  33.                 this.message = e.getMessage();
  34.                 this.details = null;
  35.                 this.status = null;
  36.         }
  37.  
  38.         public WebappException(Exception e, HttpStatus status) {
  39.                 super(e);
  40.                 this.message = e.getMessage();
  41.                 this.details = null;
  42.                 this.status = status;
  43.         }
  44.  
  45.         public WebappException(String message, Object details, HttpStatus status) {
  46.                 this.message = message;
  47.                 this.details = details;
  48.                 this.status = status;
  49.         }
  50.  
  51.         public WebappException(String message, HttpStatus status) {
  52.                 this.message = message;
  53.                 this.details = message;
  54.                 this.status = status;
  55.         }
  56.  
  57. }

Editor

You can edit this paste and save as new:


File Description
  • exception
  • Paste Code
  • 29 Apr-2024
  • 1.07 Kb
You can Share it: