Skip to content

Commit 4508342

Browse files
nipunn1313djbalin
authored and
Convex, Inc.
committed
convex-backend PR 59: Improve .unique() error message: print document _ids (#35342)
Makes the error message thrown by `.unique()` more useful. The `_id`'s of the first two documents returned by the `unique()` query are printed in the error message. This is very helpful to the user in identifying and resolving incorrect data. Feel free to change my wording in the error message - but in my opinion it should be clear that the document id's printed are *not* all the documents returned by the `unique()` query but just the first two. I [built the Convex backend locally](https://github.com/get-convex/convex-backend/blob/ad552652f4aaa0225e977ed7f5d92a35108b85d4/BUILD.md), made this change locally, and ran the tutorial demo to verify that it works as expected. ---- By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice. Co-authored-by: Jan Balin <[email protected]> GitOrigin-RevId: 816362f3274acabe1440eda6c6d993a94160009e
1 parent 4b7dd16 commit 4508342

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

Diff for: npm-packages/convex/src/server/impl/query_impl.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -326,7 +326,8 @@ export class QueryImpl implements Query<GenericTableInfo> {
326326
return null;
327327
}
328328
if (first_two_array.length === 2) {
329-
throw new Error("unique() query returned more than one result");
329+
throw new Error(`unique() query returned more than one result:
330+
[${first_two_array[0]._id}, ${first_two_array[1]._id}, ...]`);
330331
}
331332
return first_two_array[0];
332333
}

0 commit comments

Comments
 (0)