{"record":{"id":"7de04b49413b4c6b","repo":"hs-web/hsweb-framework","slug":"e-getmessage","errorCode":null,"errorMessage":"e.getMessage()","messagePattern":"e\\.getMessage\\(\\)","errorType":"http","errorClass":"NullPointerException","httpStatus":500,"severity":"warning","filePath":"hsweb-commons/hsweb-commons-crud/src/main/java/org/hswebframework/web/crud/web/CommonWebMvcErrorControllerAdvice.java","lineNumber":180,"sourceCode":"    @Order\n    public ResponseMessage<Object> handleException(HttpMessageNotReadableException e) {\n        return ResponseMessage\n            .error(400,\n                   \"missing_request_body\",\n                   LocaleUtils.resolveMessage(\"error.missing_request_body\"));\n    }\n\n    @ExceptionHandler\n    @ResponseStatus(HttpStatus.INTERNAL_SERVER_ERROR)\n    public ResponseMessage<Object> handleException(NullPointerException e) {\n        log.warn(e.getLocalizedMessage(), e);\n        return ResponseMessage.error(e.getMessage());\n    }\n\n    @ExceptionHandler\n    @ResponseStatus(HttpStatus.BAD_REQUEST)\n    public ResponseMessage<Object> handleException(IllegalArgumentException e) {\n        log.warn(e.getLocalizedMessage(), e);\n\n        return ResponseMessage.error(400, CodeConstants.Error.illegal_argument, resolveMessage(e));\n    }\n\n    @ExceptionHandler\n    @ResponseStatus(HttpStatus.BAD_REQUEST)\n    public ResponseMessage<Object> handleException(AuthenticationException e) {\n        log.warn(e.getLocalizedMessage(), e);\n\n        return ResponseMessage.error(400, e.getCode(), resolveMessage(e));\n    }\n\n    @ExceptionHandler\n    @ResponseStatus(HttpStatus.UNSUPPORTED_MEDIA_TYPE)\n    public ResponseMessage<Object> handleException(UnsupportedMediaTypeStatusException e) {\n        log.warn(e.getLocalizedMessage(), e);\n\n        return ResponseMessage","sourceCodeStart":162,"sourceCodeEnd":198,"githubUrl":"https://github.com/hs-web/hsweb-framework/blob/b2cfc85a57c70bf5b5cf6e7edae2d37102652ec8/hsweb-commons/hsweb-commons-crud/src/main/java/org/hswebframework/web/crud/web/CommonWebMvcErrorControllerAdvice.java#L162-L198","documentation":"In the servlet (WebMvc) variant of the error advice, IllegalArgumentException is mapped to HTTP 400 with code illegal_argument and a message resolved via resolveMessage(e) — which tries to localize e.getMessage(). The 'e.getMessage()' placeholder indicates the raw IllegalArgumentException text is what a client normally sees when no localized key matches. This fires for argument-validation failures inside MVC controllers/services.","triggerScenarios":"A controller/service calls e.g. Assert/Assert.notNull, StringUtils checks, or throws new IllegalArgumentException(\"...\") for bad request parameters in a Spring MVC (non-WebFlux) deployment, reaching the handleException(IllegalArgumentException) at line 180.","commonSituations":"Missing or malformed query/body parameters; hsweb dynamic-query term strings with bad syntax (like the DimensionTerm error); programmatic validation in service layer; enum parsing of user input.","solutions":["Fix the caller to supply the required argument/value described in the exception message.","Validate inputs at the edge with @Valid/@NotNull or explicit checks so users get field-level 400 errors.","Use a localized message key as the IllegalArgumentException text so resolveMessage(e) yields a translatable message.","Prefer dedicated exceptions (NotFoundException, ForbiddenException) for non-argument failures to get correct HTTP codes."],"exampleFix":"// before\nthrow new IllegalArgumentException(\"id is null\");\n// after\nthrow new IllegalArgumentException(\"error.id_not_null\"); // resolvable via i18n bundle","handlingStrategy":"validation","validationCode":"// Java caller-side check mirroring server expectations\nif (id == null || id.isEmpty()) {\n    throw new IllegalArgumentException(\"error.id_required\");\n}","typeGuard":null,"tryCatchPattern":"try {\n    return controller.handle(param);\n} catch (IllegalArgumentException e) {\n    return ResponseMessage.error(400, \"illegal_argument\",\n        LocaleUtils.resolveMessage(e.getMessage(), e.getMessage()));\n}","preventionTips":["Use @Valid/@Validated and bean-validation annotations on DTOs.","Use i18n message keys as IllegalArgumentException messages.","Check term/query DSL strings against documented formats before sending.","Cover validation branches with unit tests."],"tags":["http-400","illegal-argument","validation","spring-mvc"],"backgroundTag":"invalid-argument-value","analyzedSha":"b2cfc85a57c70bf5b5cf6e7edae2d37102652ec8","analyzedAt":"2026-09-13T09:05:02.172Z","contentChangedAt":"2026-09-13T09:05:02.172Z","schemaVersion":2},"datasetVersion":"2026-09-16T04:17:20.429Z"}