added logs in masterdataserviceimpl

This commit is contained in:
himanshu
2025-11-04 02:59:38 +05:30
parent f7c2669d11
commit 7d6db124e7
10 changed files with 282 additions and 110 deletions
@@ -39,4 +39,23 @@ public class GlobalExceptionHandler {
return new ResponseEntity<>(response, HttpStatus.BAD_REQUEST);
}
}
// ✅ NEW: Handle ALL other exceptions (Generic Handler)
@ExceptionHandler(Exception.class)
public ResponseEntity<ResponseModel<?>> handleAllExceptions(Exception ex) {
// ✅ Internal logging (tumhare system ko pata chale)
System.err.println("INTERNAL SERVER ERROR: " + ex.getMessage());
ex.printStackTrace(); // Stack trace for debugging
// ✅ Client ko generic message
ResponseModel<?> response = new ResponseModel<>(
"Service temporarily unavailable. Please try again later.",
"FAILED",
HttpStatus.INTERNAL_SERVER_ERROR.value(),
null
);
return new ResponseEntity<>(response, HttpStatus.INTERNAL_SERVER_ERROR);
}
}