Discussion:
[racket] What's the idomatic way to handle system call errors?
Jack Firth
2015-03-13 20:27:25 UTC
Permalink
I'm using racket/system to make some calls to other processes, which upon
failure write to standard error. What's the proper way to handle this? I've
been using with-output-to-string to get the output, but I don't know how I
can turn an error response from the external system command into something
in Racket I can work with. Is there some idiomatic with-error-as-exception
form or something similar that says "if this thunk writes to standard
error, throw an exception with the output in the message"?
Eric Dong
2015-03-14 03:10:23 UTC
Permalink
I suppose this is a non-answer, but it shouldn't be hard at all to write a
"with-error-as-exception" form. I generally believe it's idiomatic to
extend the language whenever something inconvenient, or whenever a
boilerplate "design pattern", comes up.
Post by Jack Firth
I'm using racket/system to make some calls to other processes, which upon
failure write to standard error. What's the proper way to handle this? I've
been using with-output-to-string to get the output, but I don't know how I
can turn an error response from the external system command into something
in Racket I can work with. Is there some idiomatic with-error-as-exception
form or something similar that says "if this thunk writes to standard
error, throw an exception with the output in the message"?
____________________
http://lists.racket-lang.org/users
Loading...