Skip to content

Cleanup error message #88

@mrleblanc101

Description

@mrleblanc101

Hi,
Would it be possible to cleanup the error messages of the forward function ?

throw new TypeError('forward did not receive an array');
throw new TypeError('forward received an array of strings, but it only accepts an array of numbers.');
throw new TypeError(`forward received an invalid longitude of ${lon}`);
throw new TypeError(`forward received an invalid latitude of ${lat}`);
throw new TypeError(`forward received a latitude of ${lat}, but this library does not support conversions of points in polar regions below 80°S and above 84°N`);

If you look at thetoPoint function, the error messages are much cleaner.

throw new Error(`MGRSPoint bad conversion from: ${mgrsString}`);
throw new Error(`MGRSPoint bad conversion from ${mgrsString}`);
throw new Error(`MGRSPoint zone letter ${zoneLetter} not handled: ${mgrsString}`);
throw new Error(`MGRSPoint has to have an even number of digits after the zone letter and two 100km letters - front half for easting meters, second half for northing meters ${mgrsString}`);

Here is what I propose:

// LatLong
throw new TypeError('LatLong: Did not receive an array');
throw new TypeError('LatLong: Received an array of strings, but expect an array of numbers.');
throw new TypeError(`LatLong: Received an invalid longitude of ${lon}`);
throw new TypeError(`LatLong: Received an invalid latitude of ${lat}`);
throw new TypeError(`LatLong: Received a latitude of ${lat}, but does not support conversions of points in polar regions below 80°S and above 84°N`);

// MGRS
throw new Error(`MGRS: Bad conversion from: ${mgrsString}`);
throw new Error(`MGRS: Bad conversion from ${mgrsString}`);
throw new Error(`MGRS: Zone letter ${zoneLetter} not handled: ${mgrsString}`);
throw new Error(`MGRS: Expect an even number of digits after the zone letter and two 100km letters - front half for easting meters, second half for northing meters ${mgrsString}`);

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions