Skip to content

Commit

Permalink
feat: Surface Salesforce load/save errors (#31)
Browse files Browse the repository at this point in the history
  • Loading branch information
zachelrath authored Nov 21, 2023
1 parent 013f7c8 commit e4bec79
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 10 deletions.
1 change: 1 addition & 0 deletions .prettierrc.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
tabWidth: 4
semi: false
useTabs: true
trailingComma: es5
overrides:
- files: "*.yaml"
options:
Expand Down
17 changes: 11 additions & 6 deletions apps/salesforce/bundle/bots/load/salesforce_load/bot.ts
Original file line number Diff line number Diff line change
Expand Up @@ -255,22 +255,27 @@ export default function salesforce_load(bot: LoadBotApi) {
let errMessage = ""
let responseObj: Record<string, object>
if (typeof response.body === "string") {
//bot.log.info("response body is string")
try {
responseObj = JSON.parse(response.body as string)
if (responseObj.error) {
errMessage = responseObj.error as unknown as string
}
// eslint-disable-next-line no-empty
} catch (e) {}
} else {
errMessage = response.body as unknown as string
} else if (response.body && typeof response.body === "object") {
if (response.body.error) {
errMessage = response.body.error as string
} else {
bot.log.error(
"unexpected error response from salesforce",
response.body
)
}
}
if (errMessage) {
bot.log.error("error from salesforce", errMessage)
bot.addError(errMessage)
bot.addError("error making salesforce request: " + errMessage)
return
}

return
}
const soqlResponse = response.body as SoqlResponse
Expand Down
14 changes: 10 additions & 4 deletions apps/salesforce/bundle/bots/save/salesforce_save/bot.ts
Original file line number Diff line number Diff line change
Expand Up @@ -243,13 +243,19 @@ export default function salesforce_save(bot: SaveBotApi) {
}
// eslint-disable-next-line no-empty
} catch (e) {}
} else {
errMessage = response.body as unknown as string
} else if (response.body && typeof response.body === "object") {
if (response.body.error) {
errMessage = response.body.error as string
}
}
if (errMessage) {
bot.log.error("error from salesforce", errMessage)
bot.addError(
"error making salesforce request: " + errMessage,
"",
""
)
return
}
// bot.addError(errMessage)
return
}
const responseBody = response.body as CompositeResponse
Expand Down

0 comments on commit e4bec79

Please sign in to comment.