hare

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

commit f7ca9eff38cc46681dc08c5bae1a6b914d067e56
parent c56eabe64f2fdf006dc4fe48bbb34ceaf7a9c89f
Author: Sebastian <sebastian@sebsite.pw>
Date:   Mon,  9 May 2022 18:37:47 -0400

encoding::json: add strerror

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

Diffstat:
Mencoding/json/types.ha | 8++++++++
1 file changed, 8 insertions(+), 0 deletions(-)

diff --git a/encoding/json/types.ha b/encoding/json/types.ha @@ -32,3 +32,11 @@ export type comma = void; // All tokens which can be returned from the JSON tokenizer. export type token = (arraystart | arrayend | objstart | objend | colon | comma | str | f64 | bool | _null); + +// Converts an [[error]] into a user-friendly string. +export fn strerror(err: error) const str = match (err) { +case invalid => + yield "Invalid JSON token encountered"; +case let err: io::error => + yield io::strerror(err); +};