Skip to content

Commit 37c8c0d

Browse files
committed
impr: error handling
1 parent e1c6b39 commit 37c8c0d

File tree

3 files changed

+41
-44
lines changed

3 files changed

+41
-44
lines changed

connect/package-lock.json

Lines changed: 25 additions & 22 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

connect/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@
4848
},
4949
"dependencies": {
5050
"@dha-team/arbundles": "1.0.3",
51-
"@permaweb/ao-core-libs": "0.0.6",
51+
"@permaweb/ao-core-libs": "0.0.7",
5252
"@permaweb/ao-scheduler-utils": "~0.0.25",
5353
"@permaweb/protocol-tag-utils": "~0.0.2",
5454
"axios": "^1.7.9",

connect/src/client/ao-core.js

Lines changed: 15 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ export function spawnWith(deps) {
6666
if (!scheduler) throw new Error('No scheduler provided')
6767
if (!module) throw new Error('No module provided')
6868

69-
const authority = process.env.AUTHORITY || scheduler
69+
const authority = process.env.AUTHORITY || args.authority || scheduler
7070

7171
debugLog('info', 'Node URL:', deps.url)
7272
debugLog('info', 'Scheduler:', scheduler)
@@ -93,21 +93,15 @@ export function spawnWith(deps) {
9393

9494
try {
9595
const processId = response.headers.get('process')
96-
9796
debugLog('info', 'Process ID:', processId)
9897

99-
if (processId) {
100-
await retryInitPush(deps, processId, 10)
101-
102-
return processId
103-
}
104-
105-
return null;
98+
if (processId) return processId;
99+
else throw new Error('Error spawning process')
106100
} catch (e) {
107-
throw new Error(e.message ?? 'Error spawning mainnet process')
101+
throw new Error(e.message ?? 'Error spawning process')
108102
}
109103
} catch (e) {
110-
throw new Error(e.message ?? 'Error spawning mainnet process')
104+
throw new Error(e.message ?? 'Error spawning process')
111105
}
112106
}
113107
}
@@ -131,9 +125,9 @@ export function messageWith(deps) {
131125
if (args.opts?.fullResponse) return convertToLegacyOutput(parsedResponse)
132126
else return parsedResponse.slot
133127
}
134-
return null
128+
else throw new Error('Error sending message')
135129
} catch (e) {
136-
throw new Error(e.message ?? 'Error sending mainnet message')
130+
throw new Error(e.message ?? 'Error sending message')
137131
}
138132
}
139133
}
@@ -153,9 +147,9 @@ export function resultWith(deps) {
153147
const parsedResponse = await response.json()
154148
return convertToLegacyOutput(parsedResponse)
155149
}
156-
return null
150+
else throw new Error('Error getting result')
157151
} catch (e) {
158-
throw new Error(e.message ?? 'Error sending mainnet message')
152+
throw new Error(e.message ?? 'Error getting result')
159153
}
160154
}
161155
}
@@ -195,14 +189,14 @@ export function resultsWith(deps) {
195189
}
196190
}
197191

198-
return null
192+
else throw new Error('Error getting results')
199193
} catch (e) {
200194
throw new Error(e.message ?? 'Error getting current process slot')
201195
}
202196
}
203-
return null
197+
else throw new Error('Error getting results')
204198
} catch (e) {
205-
throw new Error(e.message ?? 'Error sending mainnet message')
199+
throw new Error(e.message ?? 'Error getting results')
206200
}
207201
}
208202
}
@@ -228,14 +222,14 @@ export function dryrunWith(deps) {
228222
const parsedResponse = await response.json()
229223
return convertToLegacyOutput(parsedResponse)
230224
}
231-
return null
225+
else throw new Error('Error running dryrun')
232226
} catch (e) {
233-
throw new Error(e.message ?? 'Error sending mainnet message')
227+
throw new Error(e.message ?? 'Error running dryrun')
234228
}
235229
}
236230
}
237231

238-
async function retryInitPush(deps, processId, maxAttempts = 10) {
232+
async function _retryInitPush(deps, processId, maxAttempts = 10) {
239233
const params = {
240234
path: `/${processId}/push`,
241235
target: processId,

0 commit comments

Comments
 (0)