Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sm/handle http error responses #980

Merged
merged 3 commits into from
Nov 10, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading