mirror of
https://github.com/Foundry376/Mailspring.git
synced 2025-01-29 03:17:47 +08:00
fix(onboarding): Message for 400+ server error codes
This commit is contained in:
parent
39afa20d22
commit
74cb7ac94f
1 changed files with 15 additions and 6 deletions
|
@ -82,6 +82,7 @@ export default class AuthenticatePage extends React.Component {
|
|||
const webview = ReactDOM.findDOMNode(this.refs.webview);
|
||||
webview.src = `${IdentityStore.URLRoot}/onboarding`;
|
||||
webview.addEventListener('did-start-loading', this.webviewDidStartLoading);
|
||||
webview.addEventListener('did-get-response-details', this.webviewDidGetResponseDetails);
|
||||
webview.addEventListener('did-fail-load', this.webviewDidFailLoad);
|
||||
webview.addEventListener('did-finish-load', this.webviewDidFinishLoad);
|
||||
webview.addEventListener('console-message', (e) => {
|
||||
|
@ -98,17 +99,25 @@ export default class AuthenticatePage extends React.Component {
|
|||
this.setState({error: null, webviewLoading: true});
|
||||
}
|
||||
|
||||
webviewDidFailLoad = ({errorCode, errorDescription, validatedURL}) => {
|
||||
webviewDidGetResponseDetails = ({httpResponseCode, originalURL}) => {
|
||||
if (httpResponseCode >= 400) {
|
||||
const error = `
|
||||
Could not reach Nylas to sign in. Please try again or contact
|
||||
support@nylas.com if the issue persists.
|
||||
(${originalURL}: ${httpResponseCode})
|
||||
`;
|
||||
this.setState({ready: false, error: error, webviewLoading: false});
|
||||
}
|
||||
};
|
||||
|
||||
webviewDidFailLoad = ({errorCode, validatedURL}) => {
|
||||
// "Operation was aborted" can be fired when we move between pages quickly.
|
||||
if (errorCode === -3) {
|
||||
return;
|
||||
}
|
||||
|
||||
let error = errorDescription;
|
||||
if (!error) {
|
||||
const e = networkErrors.createByCode(errorCode);
|
||||
error = `Could not reach ${validatedURL}. ${e ? e.message : errorCode}`;
|
||||
}
|
||||
const e = networkErrors.createByCode(errorCode);
|
||||
const error = `Could not reach ${validatedURL}. ${e ? e.message : errorCode}`;
|
||||
this.setState({ready: false, error: error, webviewLoading: false});
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue