-
Notifications
You must be signed in to change notification settings - Fork 33
Open
Description
When a handler crashes, this can be somewhat ideal at times. But ideally not regularly.
For example errors report as:
<<"Caught error in websocket handler">>
But maybe we can put the reason in the error string. This would help a lot in figuring out what is causing the error.
fn handle_ws_message(state: Socket, conn, message) {
case message {
mist.Binary(json) -> {
case decode_type(message) {
Ok(RatingType("rating")) -> {
let assert Ok(_) = mist.send_binary_frame(conn, <<image:utf8>>)
}
}
}
...
}import gleam/erlang
logger.error(string.concat(["Caught error in websocket handler: ", erlang.format(reason)]))<<"Caught error in websocket handler: {errored,{case_clause,{ok,{rating_type,<<\"rating\">>}}}}">>
Would make it a lot easier to find these errors, even if it requires translating the erlang response. I would also love the ability to turn on stack traces but I did some poking around and couldn't find support in gleam for them.
Thank you for reading.
Edit:
Another example. Maybe it could be cleaned up a little more or handled differently.
<<"Caught error in websocket handler: {errored,#{function => <<\"handle_json_message\">>,line => 123,\n message => <<\"Assertion pattern match failed\">>,\n module => <<\"image_scorer\">>,\n value => {error,{bit_decode,<<\"Could not decode base64\">>}},\n gleam_error => let_assert}}">>
Metadata
Metadata
Assignees
Labels
No labels