skoshx / pentagon

Prisma-like ORM built on top of Deno KV. Allows you to write your database schemas and relations using Zod schemas, and run queries using familiar syntax from Prisma.
https://dash.deno.com/playground/pentagon-demo
MIT License
153 stars 4 forks source link

suggest: helpful error messages on failed batched operations #35

Open not-ivy opened 1 year ago

not-ivy commented 1 year ago

Currently, I am having an issue with creating entries in my db, and it only fails with this stacktrace:

error: Uncaught Error: Could not perform batched create operation.
      throw new PentagonBatchOpError(
            ^
    at withBatchedOperation (https://deno.land/x/pentagon@v0.1.4/src/batchOperations.ts:36:13)
    at eventLoopTick (ext:core/01_core.js:183:11)
    at async createMany (https://deno.land/x/pentagon@v0.1.4/src/crud.ts:135:41)
    at async create (https://deno.land/x/pentagon@v0.1.4/src/crud.ts:124:11)
    at async createImpl (https://deno.land/x/pentagon@v0.1.4/src/pentagon.ts:62:10)

it would be more helpful to provide more details on why the operation was failed when invoking res.commit().

not-ivy commented 1 year ago

here is the playground to reproduce this error: https://dash.deno.com/playground/pentagon-reproduce-35

skoshx commented 1 year ago

Hello, I understand your frustration with the errors being quite "cryptic". One of the contributing factors to this is that Deno KV doesn't return anything other than ok: false when an error occurs, so creating more helpful error messages is somewhat tricky.

We will keep this open for now, and at some time implement helper functions that tries to find which versionstamps / schemas are cuasing the operations to fail.

Btw, I can't access the playground for some reason, it just redirects me to the login page, or to my projects page... Is the playground marked as public?

not-ivy commented 11 months ago

sorry, it was marked as private. it should be open now