Handle idris errors

This commit is contained in:
Nathan McCarty 2024-12-30 14:14:19 +00:00
parent 2784a7d80a
commit 525b9c68cd
2 changed files with 6 additions and 8 deletions

View file

@ -9,7 +9,7 @@ my $ide = IUtils::IDEMode.new();
my @res = $ide.version;
say @res[0][1][1][1][0];
@res = $ide.load-file: '.tmp/test.idr';
@res = $ide.load-file: '.tmp/test.nope';
say @res.raku;
@res = $ide.interpret: ':exec works >>= print';

View file

@ -43,11 +43,7 @@ class SExp::Actions {
}
method str-content($/) {
if $/.Str && $0 {
make $/.Str.subst(/\\(.)/, {$0}, :g)
} else {
make ''
}
make $/.Str.subst(/\\(.)/, {$0}, :g)
}
}
@ -94,7 +90,6 @@ method process-protocol-version() {
method read-sexp() {
my $len = $!socket.read(6).decode('utf8');
my $msg = $!socket.read(:bin, $len.parse-base(16)).decode('utf8');
# say "Got: ", $len, $msg;
SExp.parse($msg, actions => SExp::Actions).made
}
@ -119,7 +114,10 @@ method send-command(*@cmd) {
my $resp = self.read-sexp();
@responses.push($resp);
# TODO: Die on error
if $resp[1][0] eq ':error' && $resp[2] == $id {
die "Idris error: ", $resp[1][1];
}
if $resp[0] eq ':return' && $resp[2] == $id {
return @responses;
}