Skip to content

Commit

Permalink
Update error message on list to be more explicit (langchain-ai#1822)
Browse files Browse the repository at this point in the history
  • Loading branch information
ralewis85 authored Jun 30, 2023
1 parent 9a69650 commit e540f3a
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions langchain/src/tools/zapier.ts
Original file line number Diff line number Diff line change
Expand Up @@ -136,8 +136,7 @@ export class ZapierNLAWrapper extends Serializable {

/**
* Executes an action that is identified by action_id, must be exposed
* (enabled) by the current user (associated with the set api_key). Change
* your exposed actions here: https://nla.zapier.com/demo/start/
* (enabled) by the current user (associated with the set api_key or access token).
* @param actionId
* @param instructions
* @param params
Expand Down Expand Up @@ -172,8 +171,7 @@ export class ZapierNLAWrapper extends Serializable {

/**
* Returns a list of all exposed (enabled) actions associated with
* current user (associated with the set api_key). Change your exposed
* actions here: https://nla.zapier.com/demo/start/
* current user (associated with the set api_key or access token).
*/
async listActions(): Promise<ZapierValues[]> {
const headers = this._getHeaders();
Expand All @@ -186,6 +184,16 @@ export class ZapierNLAWrapper extends Serializable {
}
);
if (!resp.ok) {
if (resp.status === 401) {
if (this.zapierNlaOAuthAccessToken) {
throw new Error(
"A 401 Unauthorized error was returned. Check that your access token is correct and doesn't need to be refreshed."
);
}
throw new Error(
"A 401 Unauthorized error was returned. Check that your API Key is correct."
);
}
throw new Error("Failed to list actions");
}
return (await resp.json()).results;
Expand Down

0 comments on commit e540f3a

Please sign in to comment.