SpotifyException.fromException constructor

SpotifyException.fromException(
  1. Exception e
)

Factory translating any generic Exception or PlatformException into a specific SpotifyException subclass.

Implementation

factory fromException(Exception e) {
  if (e is SpotifyException) {
    return e;
  }
  if (e is MissingPluginException) {
    return SpotifyUnimplementedException(
      e.message ?? 'Method not implemented on this platform',
      cause: e,
    );
  }
  if (e is PlatformException) {
    return SpotifyException.fromPlatformException(e);
  }
  return SpotifyGeneralException(e.toString(), cause: e);
}