hare

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

commit 8404561b565362a1794596799a7925923c0ce769
parent 2d2782ce39cb00448068633542be4705eefa8e3b
Author: Drew DeVault <sir@cmpwn.com>
Date:   Mon,  1 Feb 2021 10:28:22 -0500

main.ha: improve error handling

Diffstat:
Mmain.ha | 14++++++++++++--
1 file changed, 12 insertions(+), 2 deletions(-)

diff --git a/main.ha b/main.ha @@ -12,15 +12,25 @@ export fn main() void = { }, }; }; + defer io::close(in); let buf: [1024]u8 = [0u8...]; for (true) { match (io::read(in, buf[..])) { err: io::error => match (err) { err: io::closed => break, - * => abort(), + * => { + io::errorln(io::errstr(err)); + os::exit(1); + }, + }, + n: size => match (io::write(os::stdout, buf[..n])) { + err: io::error => { + io::errorln(io::errstr(err)); + os::exit(1); + }, + * => void, }, - n: size => io::write(os::stdout, buf[..n]), }; }; };