Commit 7c689762 by Khazretsultan

nce integration

parents
package kz.neos.arc.exception;
import lombok.Data;
import org.springframework.http.HttpStatus;
import java.time.ZonedDateTime;
@Data
public class ApiException {
private final String message;
private final HttpStatus httpStatus;
private final ZonedDateTime zonedDateTime;
public ApiException(String message, Throwable throwable, HttpStatus httpStatus, ZonedDateTime zonedDateTime) {
this.message = message;
this.httpStatus = httpStatus;
this.zonedDateTime = zonedDateTime;
}
}
package kz.neos.arc.exception;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import java.time.ZoneId;
import java.time.ZonedDateTime;
@ControllerAdvice
public class ApiExceptionHandler {
@ExceptionHandler(value = {ApiRequestException.class})
public ResponseEntity<?> handlerApiRequestException(ApiRequestException e) {
HttpStatus badRequest = HttpStatus.BAD_REQUEST;
ApiException apiException = new ApiException(
e.getMessage(),
e,
HttpStatus.BAD_REQUEST,
ZonedDateTime.now(ZoneId.of("Z"))
);
return new ResponseEntity<>(apiException, badRequest);
}
}
package kz.neos.arc.exception;
public class ApiRequestException extends RuntimeException {
public ApiRequestException(String message) {
super(message);
}
public ApiRequestException(String message, Throwable cause) {
super(message, cause);
}
}
package kz.neos.arc.exception;
/**
* Author: Khazretsultan Zhiyentayev
* Date: 01.03.2021
* Time: 21:47
* e-mail: zhiyentayev.khazretsultan@gmail.com
*/
public class SampleException extends RuntimeException {
public SampleException(String message) {
super(message);
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment