Skip to content

Commit

Permalink
refactor(engine-rest): ensure proper exception code assignment in Exc…
Browse files Browse the repository at this point in the history
…eptionHandlerHelper (camunda#4600)

camunda#4824
  • Loading branch information
yhao3 authored Nov 29, 2024
1 parent 736692f commit 091ec02
Showing 1 changed file with 9 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,6 @@ public Response getResponse(Throwable throwable) {
Response.Status responseStatus = getStatus(throwable);
ExceptionDto exceptionDto = fromException(throwable);

provideExceptionCode(throwable, exceptionDto);

return Response
.status(responseStatus)
.entity(exceptionDto)
Expand Down Expand Up @@ -85,17 +83,21 @@ protected Integer getCode(Throwable throwable) {
}

public ExceptionDto fromException(Throwable e) {
ExceptionDto exceptionDto;
if (e instanceof MigratingProcessInstanceValidationException) {
return MigratingProcessInstanceValidationExceptionDto.from((MigratingProcessInstanceValidationException)e);
exceptionDto = MigratingProcessInstanceValidationExceptionDto.from((MigratingProcessInstanceValidationException)e);
} else if (e instanceof MigrationPlanValidationException) {
return MigrationPlanValidationExceptionDto.from((MigrationPlanValidationException)e);
exceptionDto = MigrationPlanValidationExceptionDto.from((MigrationPlanValidationException)e);
} else if (e instanceof AuthorizationException) {
return AuthorizationExceptionDto.fromException((AuthorizationException)e);
exceptionDto = AuthorizationExceptionDto.fromException((AuthorizationException)e);
} else if (e instanceof ParseException){
return ParseExceptionDto.fromException((ParseException) e);
exceptionDto = ParseExceptionDto.fromException((ParseException) e);
} else {
return ExceptionDto.fromException(e);
exceptionDto = ExceptionDto.fromException(e);
}
provideExceptionCode(e, exceptionDto);

return exceptionDto;
}

public Response.Status getStatus(Throwable exception) {
Expand Down

0 comments on commit 091ec02

Please sign in to comment.