wrap static method
OtpCryptoException
wrap(
- Object error, {
- required String code,
- required String message,
- StackTrace? stackTrace,
Wraps any error
as an OtpCryptoException with the given code
and
generic message
. If error
is already an OtpCryptoException, it is
returned unchanged.
HINT: Use in catch blocks to ensure uniform, safe error reporting.
Implementation
static OtpCryptoException wrap(
Object error, {
required String code,
required String message,
StackTrace? stackTrace,
}) {
if (error is OtpCryptoException) return error;
return OtpCryptoException(
code,
message,
cause: error,
stackTrace: stackTrace,
);
}