resource
resource copied to clipboard
Unify Exceptions for io and web
Resource.readAsBytes()
and friends throw different exceptions depending on which platform is being used. Given that dart:io
and dart:html
are generally mutually exclusive, there's no way to safely type-test thrown exceptions using something like on FileSystemException catch (e)
.
This package could throw its own exceptions instead with fields filled from the corresponding platform-specific exception classes.
-
io_io.dart
throws one of:class FileSystemException implements IOException { final String message; final String path; final OSError osError; } class HttpException implements IOException { final String message; final Uri uri; }
-
io_html.dart
should check HTTP response code and throw from_httpGetBytes
.
Common API could look like:
class ResourceException {
final String message;
final Uri uri;
final Uri resolvedUri;
}