Handlers

TanayLabUtilities.Handlers.AbnormalHandler Type

The action to take when encountering an "abnormal" (but recoverable) operation.

Valid values are:

IgnoreHandler - ignore the issue and perform the recovery operation.

WarnHandler - emit a warning using @warn and perform the recovery operation.

ErrorHandler - abort the program with an error message.

TanayLabUtilities.Handlers.handle_abnormal Function
handle_abnormal(message::Function, handler::AbnormalHandler)::Nothing
handle_abnormal(handler::AbnormalHandler, message::AbstractString)::Nothing

Call this when encountering some abnormal, but recoverable, condition. Follow it by the recovery code ( handle_abnormal(abnormal_handler, "message"); recovery... or handle_abnormal(abnormal_handler) do return "...message..." end; recovery... ).

This will error if the handler is ErrorHandler , and abort the program with the message . If it is WarnHandler , it will just @warn and return. If it is IgnoreHandler it will just return.

If message is a function, it should return the actual message to error with.

handle_abnormal(IgnoreHandler, "message")

# output


handle_abnormal(IgnoreHandler) do
    @assert false
end

# output


handle_abnormal(ErrorHandler, "message")

# output

ERROR: message

handle_abnormal(ErrorHandler) do
    return "message"
end

# output

ERROR: message

handle_abnormal(WarnHandler, "message")

# output

┌ Warning: message
└ @ TanayLabUtilities.Handlers

handle_abnormal(WarnHandler) do
    return "message"
end

# output

┌ Warning: message
└ @ TanayLabUtilities.Handlers

Index