Skip to content

Commit

Permalink
fix: add better error message to bad annotation read
Browse files Browse the repository at this point in the history
  • Loading branch information
dickermoshe committed Sep 24, 2024
1 parent 8fbd10b commit b87dc23
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion drift/lib/src/runtime/manager/annotate.dart
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,12 @@ class Annotation<SqlType extends Object, $Table extends Table>

/// Read the result of the annotation from the [BaseReferences] object
SqlType? read(BaseReferences refs) {
return refs.$_typedResult.read(_expression);
try {
return refs.$_typedResult.read(_expression);
} on ArgumentError {
throw ArgumentError('This annotation has not been added to the query. '
'Use the .withAnnotations(...) method to add it to the query. ');
}
}

/// Create a new annotation
Expand Down

0 comments on commit b87dc23

Please sign in to comment.