Skip to content

Commit

Permalink
Merge pull request #980 from forcedotcom/sm/handle-http-error-responses
Browse files Browse the repository at this point in the history
Sm/handle http error responses
  • Loading branch information
WillieRuemmele authored Nov 10, 2023
2 parents b3c1d6b + 49e5e58 commit baac2df
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
10 changes: 10 additions & 0 deletions messages/org.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,3 +65,13 @@ We found more than one SandboxProcess with the SandboxName %s.
# sandboxNotResumable

The sandbox %s cannot resume with status of %s.

# UnexpectedResponse

Unexpected response from the platform

# UnexpectedResponse.actions

- Check that the instance URL is correct and the org still exists.

- See what's at the URL that's causing the problem: %s.
11 changes: 10 additions & 1 deletion src/org/org.ts
Original file line number Diff line number Diff line change
Expand Up @@ -699,7 +699,16 @@ export class Org extends AsyncOptionalCreatable<Org.Options> {
method: 'GET',
};
const conn = this.getConnection();
await conn.request(requestInfo);
try {
await conn.request(requestInfo);
} catch (e) {
// an html error page like https://computing-connect-6970-dev-ed.scratch.my.salesforce.com/services/data/v50.0
// where the message is an entire html page
if (e instanceof Error && (e.name.includes('ERROR_HTTP') || e.message.includes('<html '))) {
throw messages.createError('UnexpectedResponse', [], [conn.baseUrl()], e);
}
throw e;
}
}

/**
Expand Down

0 comments on commit baac2df

Please sign in to comment.