escript error handling

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

escript error handling

Anthony Howe
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.

--
Anthony C Howe                                            SnertSoft
[hidden email]       Twitter: SirWumpus       BarricadeMX & Milters
http://snert.com/      http://nanozen.info/     http://snertsoft.com/
_______________________________________________
erlang-questions mailing list
[hidden email]
http://erlang.org/mailman/listinfo/erlang-questions
Reply | Threaded
Open this post in threaded view
|

Re: escript error handling

Mikael Pettersson-5
On Mon, Feb 25, 2019 at 6:23 PM Anthony Howe <[hidden email]> 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.
_______________________________________________
erlang-questions mailing list
[hidden email]
http://erlang.org/mailman/listinfo/erlang-questions