Skip to content

Commit

Permalink
[kbss-cvut/termit-ui#553] Handle unsupported text analysis language e…
Browse files Browse the repository at this point in the history
…xception - return 409 status.
  • Loading branch information
ledsoft committed Nov 19, 2024
1 parent f44f7b0 commit 58c10e2
Showing 1 changed file with 10 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
import cz.cvut.kbss.termit.exception.TermItException;
import cz.cvut.kbss.termit.exception.UnsupportedOperationException;
import cz.cvut.kbss.termit.exception.UnsupportedSearchFacetException;
import cz.cvut.kbss.termit.exception.UnsupportedTextAnalysisLanguageException;
import cz.cvut.kbss.termit.exception.ValidationException;
import cz.cvut.kbss.termit.exception.WebServiceIntegrationException;
import cz.cvut.kbss.termit.exception.importing.UnsupportedImportMediaTypeException;
Expand Down Expand Up @@ -99,7 +100,8 @@ private static ErrorInfo errorInfo(HttpServletRequest request, Throwable e) {
}

private static ErrorInfo errorInfo(HttpServletRequest request, TermItException e) {
return ErrorInfo.createParametrizedWithMessage(e.getMessage(), e.getMessageId(), request.getRequestURI(), e.getParameters());
return ErrorInfo.createParametrizedWithMessage(e.getMessage(), e.getMessageId(), request.getRequestURI(),
e.getParameters());
}

@ExceptionHandler(PersistenceException.class)
Expand Down Expand Up @@ -290,4 +292,11 @@ public ResponseEntity<ErrorInfo> uriSyntaxException(HttpServletRequest request,
.addParameter("char", Character.toString(e.getInput().charAt(e.getIndex())));
return new ResponseEntity<>(errorInfo(request, exception), HttpStatus.CONFLICT);
}

@ExceptionHandler
public ResponseEntity<ErrorInfo> unsupportedTextAnalysisLanguageException(HttpServletRequest request,
UnsupportedTextAnalysisLanguageException e) {
logException(e, request);
return new ResponseEntity<>(errorInfo(request, e), HttpStatus.CONFLICT);
}
}

0 comments on commit 58c10e2

Please sign in to comment.