Best Cerberus-source code snippet using org.cerberus.api.controllers.handlers.RestExceptionHandler.handleAccessDeniedException
Source:RestExceptionHandler.java
...130 return this.buildResponseEntity(responseWrapper);131 }132 @ExceptionHandler({BadCredentialsException.class})133 @ResponseStatus(HttpStatus.UNAUTHORIZED)134 protected ResponseEntity<Object> handleAccessDeniedException(final BadCredentialsException ex, final WebRequest request) {135 ResponseWrapper<Object> responseWrapper = new ResponseWrapper<>(HttpStatus.UNAUTHORIZED);136 responseWrapper.setMessage(ex.getMessage());137 return buildResponseEntity(responseWrapper);138 }139 @ExceptionHandler({DataAccessException.class, FailedInsertOperationException.class})140 @ResponseStatus(HttpStatus.INTERNAL_SERVER_ERROR)141 protected ResponseEntity<Object> handleDatabaseException(final RuntimeException ex, final WebRequest request) {142 ResponseWrapper<Object> responseWrapper = new ResponseWrapper<>(HttpStatus.INTERNAL_SERVER_ERROR);143 responseWrapper.setMessage(ex.getMessage());144 return buildResponseEntity(responseWrapper);145 }146 private ResponseEntity<Object> buildResponseEntity(ResponseWrapper<Object> responseWrapper) {147 return new ResponseEntity<>(responseWrapper, responseWrapper.getStatus());148 }...
Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!