Error Handling

Websockets are inherently asynchronous, so error handling can be inflexible.

SimpleWebsockets.jl offers the user event hooks to register callbacks and handle errors flexibly.

SEE: Server Events, Client Events, Connection Events

If no callbacks are registered, hardcoded @info, @warn and @error calls will provide logging feedback, but the parent process will remain unaffected by exceptions unless as below.

Errors in user provided callback error handlers will log the error and exit the process.

Unregistered callbacks for the following situations will log the error and exit the process:

  • A error occured in a user provided callback function
  • The client/server could not initialise on the network

WebsocketError

SimpleWebsockets.WebsocketErrorType
abstract type WebsocketError <: Exception

WebsocketError child error types have the following fields:

  • msg::String
  • log::Function

The log() function will internally call: @error msg exception = (err, trace)

Where trace is the backtrace of the exception origin.

source

WebsocketError types