hare

[hare] The Hare programming language
git clone https://git.torresjrjr.com/hare.git
Log | Files | Refs | README | LICENSE

commit abf3cd1faa7197845ac8d4e0425b768a5391052f
parent 4f73b863072e31710541293bcbeac73103d1799f
Author: Sebastian <sebastian@sebsite.pw>
Date:   Tue, 18 Jul 2023 18:56:48 -0400

strconv: improve error messages

When combined with the previous patch, this makes it so when a negative
number is used where an unsigned integer is expected, the error message
doesn't say "Input string is not an integer"; it correctly states that
the requested number doesn't fit.

Likewise, when invalid is returned from stof64 et al, the error message
doesn't say that "Input string is not an integer".

Signed-off-by: Sebastian <sebastian@sebsite.pw>

Diffstat:
Mstrconv/types.ha | 12++++++------
1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/strconv/types.ha b/strconv/types.ha @@ -3,12 +3,12 @@ // (c) 2021 Drew DeVault <sir@cmpwn.com> // (c) 2021 Ember Sawady <ecs@d2evs.net> -// Indicates that the input string is not an integer. Contains the index of the -// first nondigit rune. +// Indicates that the input string doesn't have the requested number format +// (integer or float). Contains the index of the first invalid rune. export type invalid = !size; -// Indicates that the input number is too large to be represented by the -// requested data type. +// Indicates that the input member can't be represented by the requested data +// type. export type overflow = !void; // Any error which may be returned from a strconv function. @@ -34,8 +34,8 @@ export type base = enum uint { export fn strerror(err: error) str = { match (err) { case invalid => - return "Input string is not an integer"; + return "Input string doesn't have the requested number format"; case overflow => - return "Input number overflows integer type"; + return "Input number doesn't fit into requested type"; }; };