Skip to content
This repository has been archived by the owner on Sep 19, 2023. It is now read-only.

Commit

Permalink
Document isExpressionError export
Browse files Browse the repository at this point in the history
  • Loading branch information
wschella committed Dec 14, 2018
1 parent 784b985 commit 50ba32a
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 6 deletions.
13 changes: 8 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,17 +32,20 @@ Note: If you want to use *aggregates*, or *exists* you should check out the [str

Sparqlee exports an Error class called `ExpressionError` from which all SPARQL related errors inherit. These might include unbound variables, wrong types, invalid lexical forms, and much more. More info on errors [here](lib/util/Errors.ts). These errors can be caught, and may impact program execution in an expected way. All other errors are unexpected, and are thus programmer mistakes or mistakes in this library.

There is also the utility function `isExpressionError` for detecting these cases.

```ts
// Make sure to catch errors if you don't control binding input
try {
const result = await evaluator.evaluate(bindings);
consumeResult(result;)
} catch (error) {
if (error instanceof ExpressionError) {
console.log(error); // SPARQL related errors
} else {
throw error; // programming errors or missing features.
}
if (isExpressionError(error)) {
console.log(error); // SPARQL related errors
... // Move on, ignore result, ...
} else {
throw error; // Programming errors or missing features.
}
}
```

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "sparqlee",
"version": "0.0.1-rc9",
"version": "0.0.1",
"description": "A simple SPARQL expression evaluator library",
"main": "dist/index.js",
"types": "dist/index.d.ts",
Expand Down

0 comments on commit 50ba32a

Please sign in to comment.