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 JSError.message as SodiumException.

Implementation

T jsErrorWrap<T>(T Function() callback) {
  try {
    return callback();
  } on JSError catch (e, s) {
    Error.throwWithStackTrace(SodiumException(e.message), s);
  }
}