Não consigo tratar a Exception oracle.jdbc.OracleDatabaseException, o spring retorna o erro da forma padrão e não como foi definida no método handle2.
package br.com.makode.beneficiariows.controller;
import org.springframework.http.HttpStatus;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseStatus;
import org.springframework.web.bind.annotation.RestControllerAdvice;
import oracle.jdbc.OracleDatabaseException;
@RestControllerAdvice
public class TratamentoDeErros {
@ResponseStatus(code = HttpStatus.BAD_REQUEST)
@ExceptionHandler(oracle.jdbc.OracleDatabaseException.class)
public String handle2(OracleDatabaseException exption) {
int codigoErro = exption.getOracleErrorNumber();
return "Erro ao rodar a Packge, erro: " + codigoErro;
}
@ResponseStatus(code = HttpStatus.OK)
@ExceptionHandler(NegativeArraySizeException.class)
public String handle(NegativeArraySizeException exption) {
return"Packge rodada com sucesso";
}
}
Exption que é retornada a baixo : 2021-05-03 11:00:07.645 ERROR 15616 --- [nio-8080-exec-4] o.a.c.c.C.[.[.[/].[dispatcherServlet] : Servlet.service() for servlet [dispatcherServlet] in context with path [] threw exception [Request processing failed; nested exception is org.springframework.orm.jpa.JpaSystemException: could not extract ResultSet; nested exception is org.hibernate.exception.GenericJDBCException: could not extract ResultSet] with root cause
oracle.jdbc.OracleDatabaseException: ORA-20001: Autorização não encontrada ORA-06512: em "BENHOM.UC_URA", line 19
at oracle.jdbc.driver.T4CTTIoer11.processError(T4CTTIoer11.java:498) ~[ojdbc8.jar:12.2.0.1.0]
at oracle.jdbc.driver.T4CTTIoer11.processError(T4CTTIoer11.java:446) ~[ojdbc8.jar:12.2.0.1.0]