How can I translate custom error message in JHipster App with Angular UI?
I have added custom exception handler:
@ExceptionHandler
default ResponseEntity<Problem> handleSomeBusinessException(final SomeBusinessException exception, final NativeWebRequest request) {
final Problem problem = Problem.builder()
.withStatus(UNPROCESSABLE_ENTITY)
.with("BusinessException", SomeBusinessException .class.getName())
.with("BusinessMessage", exception.getMessage())
.build();
return create(exception, problem, request);
}
Next I modified alert-error.component.ts
this.httpErrorListener = eventManager.subscribe('someApp.httpError', (response: JhiEventWithContent<HttpErrorResponse>) => {
const httpErrorResponse = response.content;
switch (httpErrorResponse.status) {
case 422:
this.addErrorAlert(httpErrorResponse.error.BusinessMessage);
break;
Unfortunately when I run app and SomeBusinessException is thrown I see follwing stuff in UI:
translation-not-found[Some business message related to SomeBusinessException]
Can you please advise where I can introduce translation of my BusinessMessage?
Update: I have checked src\main\webapp\i18n\en\error.json but it is bound to http.code, not to message itself