@devries-cameron20 / composio Mirror · read-only
Fork 0

Composio powers 1000+ toolkits, tool search, context management, authentication, and a sandboxed workbench to help you build AI agents that turn intent into action.

Mirrored from https://github.com/Camo67/composio.git

Synced Nov 21, 04:45 UTC

next
ts 52 lines 1015 Bytes
Raw
1 import { Composio } from '@composio/core';
2 import { ComposioError } from '@composio/core';
3
4 async function level3() {
5 throw new ComposioError('Level 3 error', {
6 code: 'LEVEL_3_ERROR',
7 cause: new Error('Original cause'),
8 });
9 }
10
11 async function level2() {
12 try {
13 await level3();
14 } catch (error) {
15 throw new ComposioError('Level 2 error', {
16 code: 'LEVEL_2_ERROR',
17 cause: error,
18 });
19 }
20 }
21
22 async function level1() {
23 try {
24 await level2();
25 } catch (error) {
26 throw new ComposioError('Level 1 error', {
27 code: 'LEVEL_1_ERROR',
28 cause: error,
29 });
30 }
31 }
32
33 async function main() {
34 try {
35 const composio = new Composio({
36 apiKey: 'test-api-key',
37 });
38
39 await level1();
40 } catch (error) {
41 if (error instanceof ComposioError) {
42 error.prettyPrint(true);
43
44 console.log('\n\nRaw stack trace:');
45 console.log(error.stack);
46 } else {
47 console.error('Unexpected error:', error);
48 }
49 }
50 }
51
52 main().catch(console.error);