[erlang-questions] escript error handling
Mikael Pettersson
mikpelinux@REDACTED
Mon Feb 25 21:21:33 CET 2019
On Mon, Feb 25, 2019 at 6:23 PM Anthony Howe <achowe@REDACTED> wrote:
>
> I have some Erlang (v19) command line tools built with "rebar3
> escriptize". I want my Erlang escript based tools to report any runtime
> errors to stderr, not stdout, since all my other error messages go to
> standard error.
>
> I've tried creating a custom error handler and disabling the tty handler:
>
> https://stackoverflow.com/questions/34250469/erlang-cowboy-runtime-errors-handling
>
> But that doesn't appear to work with an escript built tool since it
> continues to write to standard out.
I faced the same issue in some command-line tools I converted from C
to Erlang, and ended up wrapping my escript entry points with a
function that catches any exception and formats it to stderr. Not
pretty, but good enough for now. I'd certainly like to see a cleaner
solution; an escript's errors going to stdout is a bug IMNSHO.
More information about the erlang-questions
mailing list