0
Before showing my problem I would like to inform you that my form is able to insert records in the database, I created an exception in my java API, the error message in the figure below is expected, however my Angular project is only able to issue generic exceptions, and I need to create an error message for this exception below and I don’t know how to do.
Watch the image:
This is the code responsible for taking the generic exception, and it is this code that you must modify in order to be able to generate a message for the specific exception with the name of NomeEstiloJaCadastradoException
import { Injectable } from '@angular/core';
import { ToastyService } from 'ng2-toasty';
@Injectable()
export class ErroHandlerService {
constructor(private toasty: ToastyService) { }
handle(errorResponse: any) {
let msg: string;
if (typeof errorResponse === 'string') {
msg = errorResponse;
} else {
msg = 'Erro ao processar serviço remoto. Tente novamente.';
console.error('Ocorreu um erro', errorResponse);
}
this.toasty.error(msg);
}
}
I know I found a model similar to mine on the internet, but I don’t know how to make this change to the system take the name exception NomeEstiloJaCadastradoException, and I need help
A small note: existing user error should return status 409.
– Andre Figueiredo
I don’t believe this is important.
– wladyband
Because that would be important?
– wladyband