jsErrorWrap<T> function

T jsErrorWrap<T>(
  1. T callback()
)

Wraps any callback to convert JsErrors to SodiumExceptions.

This simply runs the callback and catches all instances of JsError and rethrows the error message as SodiumException.

Implementation

T jsErrorWrap<T>(T Function() callback) {
  try {
    return callback();
  } on JsError catch (e) {
    throw SodiumException(e.message);
  }
}