Skip to content

Commit

Permalink
Merge pull request #50 from TTG-Club/hotfix/api-excrption
Browse files Browse the repository at this point in the history
Исправление сокрытия сообщения исключения
  • Loading branch information
Magistrus authored Jan 14, 2025
2 parents b3a6b9f + 4821c6c commit e0279ed
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 13 deletions.
21 changes: 9 additions & 12 deletions src/main/java/club/ttg/dnd5/exception/ApiException.java
Original file line number Diff line number Diff line change
@@ -1,11 +1,17 @@
package club.ttg.dnd5.exception;

import lombok.Getter;
import org.springframework.http.HttpStatus;

import java.io.Serial;

@Getter
public class ApiException extends RuntimeException {
private static final long serialVersionUID = 1L;
private HttpStatus status;
private String message;
@Serial
private static final long serialVersionUID = 1L;

private final HttpStatus status;
private final String message;

public ApiException(HttpStatus status, String message) {
this.status = status;
Expand All @@ -17,13 +23,4 @@ public ApiException(String message, HttpStatus status, String message1) {
this.status = status;
this.message = message1;
}

public HttpStatus getStatus() {
return status;
}

@Override
public String getMessage() {
return message;
}
}
2 changes: 1 addition & 1 deletion src/main/java/club/ttg/dnd5/service/user/AuthService.java
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ public String signIn(String usernameOrEmail, String password, Boolean remember)
} catch (DisabledException e) {
throw new ApiException(HttpStatus.UNAUTHORIZED, "Учетная запись не активирована");
} catch (Exception e) {
throw new ApiException(HttpStatus.INTERNAL_SERVER_ERROR, "Неизвестная ошибка");
throw new ApiException(HttpStatus.INTERNAL_SERVER_ERROR, e.getMessage());
}

User user = userService.getByUsernameOrEmail(usernameOrEmail);
Expand Down

0 comments on commit e0279ed

Please sign in to comment.