markLibraryLoadFailure function
error, thrown while a library loaded, marked as a LibraryLoadFailure
of the same kind; anything else (an Error that is no load failure) as it
is.
Implementation
Object markLibraryLoadFailure(Object error) => switch (error) {
LibraryLoadFailure() => error,
ArgumentError(:final message) => LibraryLoadArgumentError('$message'),
StateError(:final message) => LibraryLoadStateError(message),
UnsupportedError(:final message) => LibraryLoadUnsupportedError(
message ?? '$error',
),
Exception() => LibraryLoadFailedException('$error'),
_ => error,
};