Skip to content
This repository was archived by the owner on Sep 14, 2021. It is now read-only.
This repository was archived by the owner on Sep 14, 2021. It is now read-only.

Unify Exceptions for io and web #45

@lexaknyazev

Description

@lexaknyazev

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;
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions