i have a rest api:
@RestController
.....
@PostMapping(value = "/v1/ms/prop")
public @ResponseBody ResponseEntity<Object> orch(@RequestBody @Valid Request request){
Response response = serv.prop(request);
return ResponseEntity.ok(response);
and serv.prop(request):
Response response = new Response ();
try {
calculate(**data**);
callExternalService();
} catch (Exception e) {
**//intercept status error code**
**// writeError(data,errorStatusCode)**
} finally {
writeAuditOperation(auditLog);
MDC.clear();
}
Inside the catch, i want, ONLY IN this api rest, intercept the type of error (400,404,500,502 ecc ecc ) and call an external service that log this error.
Thanks for the help