Skip to content

Commit

Permalink
fix: 🐛 improve error message on create
Browse files Browse the repository at this point in the history
  • Loading branch information
dennemark committed Aug 16, 2024
1 parent 246f06a commit bffbd83
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/filterQueryResults.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,12 @@ export function filterQueryResults(result: any, mask: any, creationTree: Creatio
const filterPermittedFields = (entry: any) => {
if (!entry) { return null }
if (creationTree?.type === 'create') {
if (!abilities.can('create', getSubject(model, entry))) {
throw new Error(`It's not allowed to create on ${model}`)
try {
if (!abilities.can('create', getSubject(model, entry))) {
throw new Error('')
}
} catch (e) {
throw new Error(`It's not allowed to create on ${model} ` + e)
}
}

Expand Down

0 comments on commit bffbd83

Please sign in to comment.