{"record":{"id":"c6f45c9dd40bb686","repo":"alibaba/COLA","slug":"errmessage","errorCode":null,"errorMessage":"${errMessage}","messagePattern":"\\$\\{errMessage\\}","errorType":"exception","errorClass":"BizException","httpStatus":null,"severity":"error","filePath":"cola-components/cola-component-exception/src/main/java/com/alibaba/cola/exception/Assert.java","lineNumber":63,"sourceCode":"\n    /**\n     * Assert a boolean expression, if expression is true, throwing {@code BizException}\n     *\n     * for example\n     *\n     * <pre class=\"code\">Assert.isFalse(i == 0, errorCode.B_ORDER_illegalNumber, \"The order number can not be zero\");</pre>\n     *\n     * This is more intuitive than isTure.\n     */\n    public static void isFalse(boolean expression, String errorCode, String errMessage) {\n        if (expression) {\n            throw new BizException(errorCode, errMessage);\n        }\n    }\n\n    public static void isTrue(boolean expression, String errMessage) {\n        if (!expression) {\n            throw new BizException(errMessage);\n        }\n    }\n\n    public static void isFalse(boolean expression, String errMessage) {\n        if (expression) {\n            throw new BizException(errMessage);\n        }\n    }\n\n    public static void isTrue(boolean expression) {\n        isTrue(expression, \"[Assertion failed] Must be true\");\n    }\n\n    public static void isFalse(boolean expression) {\n        isFalse(expression, \"[Assertion failed] Must be false\");\n    }\n\n    public static void notNull(Object object, String errorCode, String errMessage) {","sourceCodeStart":45,"sourceCodeEnd":81,"githubUrl":"https://github.com/alibaba/COLA/blob/352e1a867538d9cd40e1b11e4028fa652fc97557/cola-components/cola-component-exception/src/main/java/com/alibaba/cola/exception/Assert.java#L45-L81","documentation":"Thrown by the Assert.isTrue/isFalse validation helper in COLA's Assert utility when the checked boolean expression fails its expectation: isFalse throws BizException with this caller-supplied message when the expression is true, and isTrue (the site here) throws when the expression is false. It is a generic argument/state guard, not a domain error — the input at fault is the expression result, and errMessage is whatever text the caller passed to Assert, so the message content itself carries no fixed semantics.","triggerScenarios":"Calling Assert.isTrue(expr, \"message\") where expr is false — e.g. validating a precondition without a formal ErrorCode.","commonSituations":"Quick inline validations in services or tests; developers omitting an ErrorCode and later needing to distinguish these BizExceptions by message only.","solutions":["Check the exception message to find which assertion failed.","Correct the input/state that made the expression false.","If a structured error code is needed, switch to the three-argument Assert.isTrue(expression, errorCode, errMessage)."],"exampleFix":"// before\nAssert.isTrue(user != null, \"User must exist\"); // BizException without code\n// after\nAssert.isTrue(user != null, ErrorCode.B_USER_notFound.getErrCode(), \"User must exist\");","handlingStrategy":"validation","validationCode":"if (user == null) {\n    return Response.buildFailure(\"USER_NOT_FOUND\", \"User must exist\");\n}\nAssert.isTrue(user != null, \"User must exist\");","typeGuard":null,"tryCatchPattern":"try {\n    Assert.isTrue(expr, errMessage);\n} catch (BizException e) {\n    log.warn(\"Assertion failed: {}\", e.getMessage());\n    return Response.buildFailure(\"ASSERTION_FAILED\", e.getMessage());\n}","preventionTips":["Prefer the three-argument overload with an ErrorCode for machine-readable failures.","Validate preconditions explicitly before relying on assertions.","Never rely on exception messages alone for branching in production code."],"tags":["assertion","validation","cola"],"backgroundTag":"invalid-argument-value","analyzedSha":"352e1a867538d9cd40e1b11e4028fa652fc97557","analyzedAt":"2026-09-08T00:46:23.972Z","contentChangedAt":"2026-09-08T00:46:23.972Z","schemaVersion":2},"datasetVersion":"2026-09-14T11:17:12.474Z"}