From b87dc237ac76b889cafadda14424a560107ab896 Mon Sep 17 00:00:00 2001 From: Moshe Dicker Date: Tue, 24 Sep 2024 08:31:52 -0400 Subject: [PATCH] fix: add better error message to bad annotation read --- drift/lib/src/runtime/manager/annotate.dart | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/drift/lib/src/runtime/manager/annotate.dart b/drift/lib/src/runtime/manager/annotate.dart index 7ac5d4711..d2e31fddc 100644 --- a/drift/lib/src/runtime/manager/annotate.dart +++ b/drift/lib/src/runtime/manager/annotate.dart @@ -28,7 +28,12 @@ class Annotation /// 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