-
Notifications
You must be signed in to change notification settings - Fork 311
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(extension/or-throw): add new extension (#1087)
- Loading branch information
1 parent
beb702e
commit aec075d
Showing
262 changed files
with
2,470 additions
and
1,658 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
36 changes: 36 additions & 0 deletions
36
examples/__outputs__/extension|extension_or-throw.output.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
---------------------------------------- SHOW ---------------------------------------- | ||
ContextualError: There was an error in the extension "anonymous" (use named functions to improve this error message) while running hook "encode". | ||
at runPipeline (/some/path/to/runPipeline.ts:XX:XX) | ||
at async Object.run (/some/path/to/main.ts:XX:XX) | ||
at async run (/some/path/to/client.ts:XX:XX) | ||
at async executeRootType (/some/path/to/client.ts:XX:XX) | ||
at async executeRootTypeField (/some/path/to/client.ts:XX:XX) | ||
at async <anonymous> (/some/path/to/extension|extension_or-throw.ts:XX:XX) { | ||
context: { | ||
hookName: 'encode', | ||
source: 'extension', | ||
extensionName: 'anonymous' | ||
}, | ||
cause: Error: Something went wrong. | ||
at <anonymous> (/some/path/to/extension|extension_or-throw.ts:XX:XX) | ||
at applyBody (/some/path/to/main.ts:XX:XX) | ||
} | ||
---------------------------------------- SHOW ---------------------------------------- | ||
UNCAUGHT EXCEPTION: | ||
|
||
ContextualError: There was an error in the extension "anonymous" (use named functions to improve this error message) while running hook "encode". | ||
at runPipeline (/some/path/to/runPipeline.ts:XX:XX) | ||
at async Object.run (/some/path/to/main.ts:XX:XX) | ||
at async run (/some/path/to/client.ts:XX:XX) | ||
at async executeRootType (/some/path/to/client.ts:XX:XX) | ||
at async executeRootTypeField (/some/path/to/client.ts:XX:XX) | ||
at async <anonymous> (/some/path/to/extension|extension_or-throw.ts:XX:XX) { | ||
context: { | ||
hookName: 'encode', | ||
source: 'extension', | ||
extensionName: 'anonymous' | ||
}, | ||
cause: Error: Something went wrong. | ||
at <anonymous> (/some/path/to/extension|extension_or-throw.ts:XX:XX) | ||
at applyBody (/some/path/to/main.ts:XX:XX) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,4 @@ | ||
---------------------------------------- SHOW ---------------------------------------- | ||
{ | ||
"data": { | ||
"foo": "bar" | ||
} | ||
"foo": "bar" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
/** | ||
* This example shows how to use the Or Throw extension to throw errors for one-off cases. | ||
*/ | ||
|
||
import { OrThrow } from '../src/entrypoints/extensions.js' | ||
import { Atlas } from './$/generated-clients/atlas/__.js' | ||
import { interceptAndShowUncaughtErrors, show } from './$/show.js' | ||
|
||
interceptAndShowUncaughtErrors() | ||
|
||
const atlas = Atlas | ||
.create({ output: { defaults: { errorChannel: `return` } } }) | ||
.use(OrThrow()) | ||
.anyware(({ encode: _ }) => { | ||
throw new Error(`Something went wrong.`) | ||
}) | ||
|
||
const result1 = await atlas.query.continents({ name: true }) | ||
show(result1) | ||
|
||
const result2 = await atlas.query.continentsOrThrow({ name: true }) | ||
result2 // This line will never be reached because of thrown error. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.