{"record":{"id":"4ee5caff7b2a2cc4","repo":"TheAlgorithms/Java","slug":"base-must-be-greater-than-01","errorCode":null,"errorMessage":"Base must be greater than 01","messagePattern":"Base must be greater than 01","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"src/main/java/com/thealgorithms/maths/Area.java","lineNumber":182,"sourceCode":"            throw new IllegalArgumentException(POSITIVE_BASE);\n        }\n        if (height <= 0) {\n            throw new IllegalArgumentException(POSITIVE_HEIGHT);\n        }\n        return baseLength * height;\n    }\n\n    /**\n     * Calculate the area of a trapezium.\n     *\n     * @param base1  upper base of trapezium\n     * @param base2  bottom base of trapezium\n     * @param height height of trapezium\n     * @return area of given trapezium\n     */\n    public static double surfaceAreaTrapezium(final double baseLength1, final double baseLength2, final double height) {\n        if (baseLength1 <= 0) {\n            throw new IllegalArgumentException(POSITIVE_BASE + 1);\n        }\n        if (baseLength2 <= 0) {\n            throw new IllegalArgumentException(POSITIVE_BASE + 2);\n        }\n        if (height <= 0) {\n            throw new IllegalArgumentException(POSITIVE_HEIGHT);\n        }\n        return (baseLength1 + baseLength2) * height / 2;\n    }\n\n    /**\n     * Calculate the area of a circle.\n     *\n     * @param radius radius of circle\n     * @return area of given circle\n     */\n    public static double surfaceAreaCircle(final double radius) {\n        if (radius <= 0) {","sourceCodeStart":164,"sourceCodeEnd":200,"githubUrl":"https://github.com/TheAlgorithms/Java/blob/fdfb9a395b310167a66bd29e311e36e0e3e9b964/src/main/java/com/thealgorithms/maths/Area.java#L164-L200","documentation":"Thrown by surfaceAreaTrapezium when the first base parameter (baseLength1) is zero or negative. The message 'Base must be greater than 01' is the result of the string constant POSITIVE_BASE ('Base must be greater than 0') being concatenated with the integer literal 1 (POSITIVE_BASE + 1), a Java string concatenation that appends '1' to the text. The intent is to distinguish this base from baseLength2, but the resulting message reads as a typo ('01').","triggerScenarios":"Calling Area.surfaceAreaTrapezium(baseLength1, baseLength2, height) where baseLength1 <= 0 (e.g., 0, -3.5, -0.001). Only the first base argument triggers this specific message; the second base triggers error 361.","commonSituations":"Parsing user-provided dimensions from a form or config file where the field was left blank (parsed as 0) or a negative sign was accidentally included. Unit conversion errors (e.g., passing millimeters as 0 after rounding) or defaulting an uninitialized double field (0.0) can also produce this.","solutions":["Ensure baseLength1 is a strictly positive value before calling surfaceAreaTrapezium (e.g., add a guard: if (baseLength1 <= 0) throw or clamp).","Check upstream data parsing — verify the source value is not blank, null-string, or negative before conversion to double.","If you control the library, fix the message bug: POSITIVE_BASE + 1 should be POSITIVE_BASE + ' 1' or a distinct constant to avoid the misleading '01' suffix."],"exampleFix":"// before\nArea.surfaceAreaTrapezium(0, 5, 3); // throws 'Base must be greater than 01'\n\n// after (caller validates)\nif (baseLength1 > 0 && baseLength2 > 0 && height > 0) {\n    Area.surfaceAreaTrapezium(baseLength1, baseLength2, height);\n}","handlingStrategy":"validation","validationCode":"// Validate trapezium baseLength1 before calling surfaceAreaTrapezium\nif (baseLength1 <= 0) {\n    throw new IllegalArgumentException(\"Trapezium base1 must be positive, got: \" + baseLength1);\n}\ndouble area = Area.surfaceAreaTrapezium(baseLength1, baseLength2, height);","typeGuard":"// For double dimensions, a simple predicate suffices\nstatic boolean isValidDimension(double value) {\n    return value > 0 && !Double.isNaN(value) && Double.isFinite(value);\n}","tryCatchPattern":null,"preventionTips":["Validate all geometric dimensions (positive and finite) at the data boundary before they reach computation.","Use a shared dimension-validation utility across all Area method calls to avoid scattered checks.","Be aware that POSITIVE_BASE + 1 produces a concatenated string '01' — if you pattern-match on error messages, account for this."],"tags":["geometry","input-validation","area","java","string-concatenation-bug"],"backgroundTag":null,"analyzedSha":"fdfb9a395b310167a66bd29e311e36e0e3e9b964","analyzedAt":"2026-08-13T23:36:13.315Z","schemaVersion":2},"datasetVersion":"2026-08-14T00:17:13.853Z"}