Generic Functions
DataAxesFormats.GenericFunctions
—
Module
Functions that arguably should belong in a more general-purpose package.
We do not re-export the functions and supporting types defined here from the top-level
DataAxesFormats
namespace. That is, even if
using DataAxesFormats
, you will
not
have these generic names polluting your namespace. If you do want to reuse them in your code, explicitly write
using DataAxesFormats.GenericFunctions
.
DataAxesFormats.GenericFunctions.dedent
—
Function
dedent(string::AbstractString; indent::AbstractString = "")::String
Given a possibly multi-line string with a common indentation in each line, strip this indentation from all lines, and replace it with
indent
. Will also strip any initial and/or final line breaks.
DataAxesFormats.GenericFunctions.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
.
ErrorHandler
- abort the program with an error message.
DataAxesFormats.GenericFunctions.handle_abnormal
—
Function
handle_abnormal(message::Function, handler::AbnormalHandler)::Nothing
Call this when encountering some abnormal, but recoverable, condition. Follow it by the recovery code.
This will
error
if the
handler
is
ErrorHandler
, and abort the program. If it is
WarnHandler
, it will just
@warn
and return. If it is
IgnoreHandler
it will just return.
The
message
is a function that should return an
AbstractString
to use. For efficiency, it is not invoked if ignoring the condition.