Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

A better exception for 'throwOnUnresolved' #316

Closed
matanlurey opened this issue Mar 7, 2018 · 1 comment
Closed

A better exception for 'throwOnUnresolved' #316

matanlurey opened this issue Mar 7, 2018 · 1 comment
Assignees
Labels
type-enhancement A request for a change that isn't a bug

Comments

@matanlurey
Copy link
Contributor

matanlurey commented Mar 7, 2018

Instead of a StateError, something that can be caught:

import 'package:analyzer/dart/element/element.dart';
import 'package:source_span/source_span.dart';

abstract class UnresolvableAnnotationException implements Exception {
  /// Element that was annotated with something we could not resolve.
  Element get annotatedElement;

  /// Source span of the annotation that was not resolved.
  SourceSpan get annotationSource;
}

So instead of a user seeing:

Bad state: Could not resolve @null. 
An import or dependency may be missing or invalid.

... we could present, for example, as a warning in AngularDart:

[WARNING] Unresolvable annotation in /some/dir/your_file.dart.

Could not resolve the "@Mispelled()" annotation on the following element:

class Foo {}
      ^^^

You may have an invalid or misspelled import or dependency.

/cc @natebosch @jakemac53 for sanity check. This is technically a breaking change (we would no longer throw StateError). I could have this implement/extend StateError, though I guess in practice we tell users not to catch errors?

@matanlurey matanlurey added the type-enhancement A request for a change that isn't a bug label Mar 7, 2018
@natebosch
Copy link
Member

SGTM. I don't think code is likely relying on the specific type now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type-enhancement A request for a change that isn't a bug
Projects
None yet
Development

No branches or pull requests

2 participants