Skip to content

Commit

Permalink
fix: throw error or return value (#131)
Browse files Browse the repository at this point in the history
  • Loading branch information
Alan Shaw authored Oct 27, 2022
1 parent 878f8c9 commit cddf7b9
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
4 changes: 4 additions & 0 deletions packages/access/src/agent.js
Original file line number Diff line number Diff line change
Expand Up @@ -266,6 +266,10 @@ export class Agent {
})
.execute(this.connection)

if (inv.error) {
throw inv
}

return inv
}
}
Expand Down
9 changes: 5 additions & 4 deletions packages/access/src/cli/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -107,11 +107,12 @@ prog
message: 'Select account:',
},
])
const result = await agent.getAccountInfo(account)
if (result.error) {
console.error(result.message)
} else {
try {
const result = await agent.getAccountInfo(account)
console.log(result)
} catch (error_) {
const error = /** @type {Error} */ (error_)
console.log(error.message)
}
} else {
console.error(`Run "${NAME} setup" first`)
Expand Down

0 comments on commit cddf7b9

Please sign in to comment.