Skip to content

Fix typo and improve clarity of radius validation error message #7260

@Adarsh-Melath

Description

@Adarsh-Melath

What would you like to share?

There is a typo and clarity issue in the error message used for radius validation in
Area.java.

Current code

private static final String POSITIVE_RADIUS = "Must be a positive radius";

public static double surfaceAreaCircle(final double radius) {
    if (radius <= 0) {
        throw new IllegalArgumentException(POSITIVE_RADIUS);
    }
    return Math.PI * radius * radius;
}

Problem

The error message "Must be a positive radius" is grammatically incorrect and does not clearly reflect the validation condition (radius <= 0).
It sounds redundant and does not explicitly indicate that zero is an invalid value.

Suggested improvement

Update the error message to better describe the constraint:

private static final String POSITIVE_RADIUS = "Radius must be greater than 0";

Additional information

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    awaiting triageAwaiting triage from a maintainer

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions