websocket: default to error code 500 on any websocket error

This commit is contained in:
Luna 2019-06-11 18:00:36 -03:00
parent 19bc38b881
commit 2f9f859be9

View file

@ -39,13 +39,13 @@ module Kemal
@proc.call(socket, context) @proc.call(socket, context)
socket.run socket.run
rescue error : Exception rescue error : Exception
if error.is_a?(WebsocketError) # TODO: check if 500 is what we're supposed to give
# TODO
context.response.status_code = 500 context.response.status_code = 500
if error.is_a?(WebsocketError)
code = error.code.to_i16 code = error.code.to_i16
message = error.status_message message = error.status_message
else else
context.response.status_code = error.code
code = 1011_i16 code = 1011_i16
message = "Exception" message = "Exception"
end end