implemented fetch qr code scanned details
This commit is contained in:
16
src/main/java/com/safeqr/app/exceptions/ErrorResponse.java
Normal file
16
src/main/java/com/safeqr/app/exceptions/ErrorResponse.java
Normal file
@@ -0,0 +1,16 @@
|
||||
package com.safeqr.app.exceptions;
|
||||
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
|
||||
@Builder
|
||||
@Data
|
||||
public class ErrorResponse {
|
||||
private String error;
|
||||
private int status;
|
||||
|
||||
public ErrorResponse(String message, int status){
|
||||
this.error = message;
|
||||
this.status = status;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
package com.safeqr.app.exceptions;
|
||||
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.web.bind.annotation.ControllerAdvice;
|
||||
import org.springframework.web.bind.annotation.ExceptionHandler;
|
||||
|
||||
@ControllerAdvice
|
||||
public class GlobalExceptionHandler {
|
||||
|
||||
@ExceptionHandler(QRCodeExceptions.class)
|
||||
public ResponseEntity<ErrorResponse> handleQRCodeNotFoundException(QRCodeExceptions e) {
|
||||
return new ResponseEntity<>(new ErrorResponse(e.getMessage(), HttpStatus.NOT_FOUND.value()), HttpStatus.NOT_FOUND);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
package com.safeqr.app.exceptions;
|
||||
|
||||
public class QRCodeExceptions extends RuntimeException {
|
||||
public QRCodeExceptions(String message){
|
||||
super(message);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user