forked from mtusi2026/mtusi2026lab5
lab5
This commit is contained in:
@@ -0,0 +1,24 @@
|
||||
package ru.mtusi.messenger;
|
||||
|
||||
public class ApiException extends RuntimeException {
|
||||
private final int status;
|
||||
private final String code;
|
||||
|
||||
public ApiException(int status, String code, String message) {
|
||||
super(message);
|
||||
this.status = status;
|
||||
this.code = code;
|
||||
}
|
||||
|
||||
public int status() { return status; }
|
||||
public String code() { return code; }
|
||||
public static ApiException invalid(String message) {
|
||||
return new ApiException(400, "invalid_request", message);
|
||||
}
|
||||
public static ApiException unauthorized() {
|
||||
return new ApiException(401, "unauthorized", "Требуется действующая Bearer-сессия");
|
||||
}
|
||||
public static ApiException notFound() {
|
||||
return new ApiException(404, "not_found", "Объект не найден");
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user