Improve error handling

This commit is contained in:
Tom Moor
2018-11-03 21:47:46 -07:00
parent 21b1c0747c
commit 6418712c47
5 changed files with 27 additions and 8 deletions

View File

@@ -51,7 +51,7 @@ class Details extends React.Component<Props> {
});
this.props.ui.showToast('Settings saved', 'success');
} catch (err) {
this.props.ui.showToast('Could not save');
this.props.ui.showToast(err.message);
}
};
@@ -127,14 +127,15 @@ class Details extends React.Component<Props> {
<Input
label="Subdomain"
name="subdomain"
value={this.subdomain}
value={this.subdomain || ''}
onChange={this.handleSubdomainChange}
placeholder="Optional"
autocomplete={false}
short
/>
{this.subdomain && (
<HelpText small>
You will be able to access your wiki at{' '}
You will access your knowledgebase at{' '}
<strong>{this.subdomain}.getoutline.com</strong>
</HelpText>
)}

View File

@@ -68,6 +68,14 @@ class ApiClient {
const error = {};
error.statusCode = response.status;
error.response = response;
try {
const data = await response.json();
error.message = data.message || '';
} catch (_err) {
// we're trying to parse an error so JSON may not be valid
}
throw error;
};