Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

FIX ITEM-460-modifier-le-libelle-dun-message-derreur : #124

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 12 additions & 1 deletion web/src/main/java/fr/abes/item/exception/ApiReturnError.java
Original file line number Diff line number Diff line change
Expand Up @@ -30,5 +30,16 @@ private ApiReturnError() {
this.debugMessage = ex.getMessage();
}


ApiReturnError(String fileCheckingError, HttpStatus status, String message, Throwable ex) {
this();
if (ex.getMessage().contains("Le fichier dépasse la limite des")) {
this.status = status;
this.message = ex.getMessage();
this.debugMessage = ex.getMessage();
} else {
this.status = status;
this.message = message;
this.debugMessage = ex.getMessage();
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,16 @@ public ResponseEntity<?> handleForbiddenFailures(Throwable t) {
@ExceptionHandler(BadCredentialsException.class)
public ResponseEntity<?> handleBadCredentials(Throwable t) { return buildResponseEntity(new ApiReturnError(HttpStatus.UNAUTHORIZED, t.getMessage(), t)); }

@ExceptionHandler({ IllegalArgumentException.class, FileCheckingException.class, FileTypeException.class})
@ExceptionHandler({ IllegalArgumentException.class, FileTypeException.class})
public ResponseEntity<?> handleMiscFailures(Throwable t) {
return buildResponseEntity(new ApiReturnError(HttpStatus.BAD_REQUEST, Constant.ERR_FILE_WRONGCONTENT, t));
}

@ExceptionHandler({ FileCheckingException.class })
public ResponseEntity<?> handleFileCheckingFailures(Throwable t) {
return buildResponseEntity(new ApiReturnError("fileCheckingError", HttpStatus.BAD_REQUEST, Constant.ERR_FILE_WRONGCONTENT, t));
}

@ExceptionHandler({ DemandeCheckingException.class })
public ResponseEntity<?> handleBadConditionsFailures(Throwable t) { return buildResponseEntity(new ApiReturnError(HttpStatus.PRECONDITION_FAILED, t.getMessage(), t));}

Expand Down
Loading