{"record":{"id":"4adef0c76b618537","repo":"pinpoint-apm/pinpoint","slug":"handlegeneralexception","errorCode":null,"errorMessage":"handleGeneralException: {}","messagePattern":"handleGeneralException: (.+?)","errorType":"http","errorClass":null,"httpStatus":500,"severity":"warning","filePath":"web/src/main/java/com/navercorp/pinpoint/web/problem/CustomExceptionHandler.java","lineNumber":88,"sourceCode":"    public CustomExceptionHandler(String hostname, ErrorProperties errorProperties) {\n        this.hostname = Objects.requireNonNull(hostname, \"hostname\");\n        this.errorProperties = Objects.requireNonNull(errorProperties, \"errorProperties\");\n    }\n\n    @ExceptionHandler({\n            org.apache.catalina.connector.ClientAbortException.class\n    })\n    public ResponseEntity<Void> handleClientAbort(Exception ex) {\n        logger.debug(\"Client disconnected: {}\", ex.getMessage());\n        return null;\n    }\n\n    @ExceptionHandler({Throwable.class})\n    public ResponseEntity<ProblemDetail> handleGeneralException(\n            Throwable ex,\n            WebRequest request\n    ) {\n        logger.warn(\"handleGeneralException: {}\", ex.getMessage(), ex);\n\n        if (ex instanceof ErrorResponse errorResponse) {\n            ProblemDetail problemDetail = errorResponse.getBody();\n            addProperties(problemDetail, request);\n            addStackTraces(problemDetail, ex);\n            return new ResponseEntity<>(problemDetail, errorResponse.getHeaders(), errorResponse.getStatusCode());\n        }\n        HttpStatus status = HttpStatus.INTERNAL_SERVER_ERROR;\n        ProblemDetail problemDetail = ProblemDetail.forStatus(status);\n        problemDetail.setTitle(status.getReasonPhrase());\n        problemDetail.setDetail(ex.getMessage());\n        addProperties(problemDetail, request);\n        addStackTraces(problemDetail, ex);\n\n        return new ResponseEntity<>(problemDetail, status);\n    }\n\n    @ExceptionHandler(AccessDeniedException.class)","sourceCodeStart":70,"sourceCodeEnd":106,"githubUrl":"https://github.com/pinpoint-apm/pinpoint/blob/744c3d3075e595656abb1ae331ad2c0e4c9eb996/web/src/main/java/com/navercorp/pinpoint/web/problem/CustomExceptionHandler.java#L70-L106","documentation":"CustomExceptionHandler.handleGeneralException is the catch-all @ExceptionHandler(Throwable.class) for the Pinpoint web REST API. Any unhandled exception reaching the controller layer is logged as a warning with its message and stack trace, then converted to an RFC-7807 ProblemDetail response (with status/headers from ErrorResponse when applicable, else a generic 500).","triggerScenarios":"Any exception not matched by a more specific @ExceptionHandler — NPEs from malformed request data, service-layer failures, unexpected IllegalStateException, etc. — thrown inside web controller/service code.","commonSituations":"Malformed query parameters reaching service code; NPEs due to missing HBase data; bugs in recently added endpoints; ErrorResponse exceptions being handled here when no dedicated handler exists.","solutions":["Read the logged stack trace to find the actual root exception in your endpoint call","Add a specific @ExceptionHandler for the concrete exception type to return a proper status code","Fix the client request (validate parameters before calling the API)","File/fix a web bug if the exception originates from valid input"],"exampleFix":"// before\n@ExceptionHandler({Throwable.class})\npublic ResponseEntity<ProblemDetail> handleGeneralException(Throwable ex, WebRequest request) {\n    logger.warn(\"handleGeneralException: {}\", ex.getMessage(), ex);\n// after\n@ExceptionHandler({Throwable.class})\npublic ResponseEntity<ProblemDetail> handleGeneralException(Throwable ex, WebRequest request) {\n    logger.error(\"handleGeneralException: {}\", ex.getMessage(), ex); // 5xx root causes deserve error level\n    Throwable root = NestedExceptionUtils.getMostSpecificCause(ex);\n    ...","handlingStrategy":"try-catch","validationCode":"// validate request params before hitting the API\nif (applicationName == null || applicationName.isBlank()) {\n    throw new MissingRequiredParamException(\"applicationName\");\n}","typeGuard":null,"tryCatchPattern":"try {\n    ResponseEntity<ProblemDetail> resp = restTemplate.getForEntity(url, ProblemDetail.class);\n} catch (HttpStatusCodeException e) {\n    ProblemDetail body = e.getResponseBodyAs(ProblemDetail.class);\n    logger.warn(\"API returned {}: {}\", e.getStatusCode(), body != null ? body.getDetail() : e.getMessage());\n}","preventionTips":["Check the server-side stack trace (logged with this warning) for the root cause","Add specific @ExceptionHandler(s) for common failure types to return accurate status codes","Validate request parameters client-side before calling the API"],"tags":["pinpoint","rest-api","exception-handling"],"backgroundTag":"api-error-response","analyzedSha":"744c3d3075e595656abb1ae331ad2c0e4c9eb996","analyzedAt":"2026-09-07T18:48:45.289Z","contentChangedAt":"2026-09-07T18:48:45.289Z","schemaVersion":2},"datasetVersion":"2026-09-17T15:17:12.973Z"}