alibaba/COLA · error · BizException
${errMessage}
Error message
${errMessage} What it means
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.
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).
Example fix
// before Assert.isTrue(user != null, "User must exist"); // BizException without code // after Assert.isTrue(user != null, ErrorCode.B_USER_notFound.getErrCode(), "User must exist");
Defensive patterns
Strategy: validation
Validate before calling
if (user == null) {
return Response.buildFailure("USER_NOT_FOUND", "User must exist");
}
Assert.isTrue(user != null, "User must exist"); Try / catch
try {
Assert.isTrue(expr, errMessage);
} catch (BizException e) {
log.warn("Assertion failed: {}", e.getMessage());
return Response.buildFailure("ASSERTION_FAILED", e.getMessage());
} Prevention
- 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.
When it happens
Trigger: Calling Assert.isTrue(expr, "message") where expr is false — e.g. validating a precondition without a formal ErrorCode.
Common situations: Quick inline validations in services or tests; developers omitting an ErrorCode and later needing to distinguish these BizExceptions by message only.
Understand the failure class
Background: "Must be a positive integer", "Invalid value", "Unsupported": the invalid-argument-value error family, when a library rejects the value you pass — this error's family across 35 libraries.
Related errors
- ${errorCode}
- B_CUSTOMER_companyNameConflict
- B_CUSTOMER_companyNameConflict
- BizScenario can not be null for extension
- has already existed, you can not add it
AI-assisted analysis of alibaba/COLA@352e1a8675 (2026-09-08).
Data as JSON: /api/errors/c6f45c9dd40bb686.
Report an issue: GitHub.
Appendix: source
Thrown at cola-components/cola-component-exception/src/main/java/com/alibaba/cola/exception/Assert.java:63
/**
* Assert a boolean expression, if expression is true, throwing {@code BizException}
*
* for example
*
* <pre class="code">Assert.isFalse(i == 0, errorCode.B_ORDER_illegalNumber, "The order number can not be zero");</pre>
*
* This is more intuitive than isTure.
*/
public static void isFalse(boolean expression, String errorCode, String errMessage) {
if (expression) {
throw new BizException(errorCode, errMessage);
}
}
public static void isTrue(boolean expression, String errMessage) {
if (!expression) {
throw new BizException(errMessage);
}
}
public static void isFalse(boolean expression, String errMessage) {
if (expression) {
throw new BizException(errMessage);
}
}
public static void isTrue(boolean expression) {
isTrue(expression, "[Assertion failed] Must be true");
}
public static void isFalse(boolean expression) {
isFalse(expression, "[Assertion failed] Must be false");
}
public static void notNull(Object object, String errorCode, String errMessage) {View on GitHub (pinned to 352e1a8675)