Improve error handling
This commit is contained in:
@@ -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>
|
||||
)}
|
||||
|
||||
@@ -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;
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user