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;
|
||||
};
|
||||
|
||||
|
||||
@@ -21,9 +21,18 @@ const Team = sequelize.define(
|
||||
allowNull: true,
|
||||
validate: {
|
||||
isLowercase: true,
|
||||
is: [/^[a-z\d-]+$/, 'i'],
|
||||
len: [4, 32],
|
||||
notIn: [RESERVED_SUBDOMAINS],
|
||||
is: {
|
||||
args: [/^[a-z\d-]+$/, 'i'],
|
||||
msg: 'Must be only alphanumeric and dashes',
|
||||
},
|
||||
len: {
|
||||
args: [4, 32],
|
||||
msg: 'Must be between 4 and 32 characters',
|
||||
},
|
||||
notIn: {
|
||||
args: [RESERVED_SUBDOMAINS],
|
||||
msg: 'You chose a restricted word, please try another.',
|
||||
},
|
||||
},
|
||||
unique: true,
|
||||
},
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
// @flow
|
||||
import parseDomain from 'parse-domain';
|
||||
|
||||
export function stripSubdomain(hostname) {
|
||||
export function stripSubdomain(hostname: string) {
|
||||
const parsed = parseDomain(hostname);
|
||||
if (parsed.tld) return `${parsed.domain}.${parsed.tld}`;
|
||||
return parsed.domain;
|
||||
|
||||
@@ -16,7 +16,8 @@ const definePlugin = new webpack.DefinePlugin({
|
||||
DEPLOYMENT: JSON.stringify(process.env.DEPLOYMENT || 'hosted'),
|
||||
'process.env': {
|
||||
URL: JSON.stringify(process.env.URL),
|
||||
SLACK_KEY: JSON.stringify(process.env.SLACK_KEY)
|
||||
SLACK_KEY: JSON.stringify(process.env.SLACK_KEY),
|
||||
SUBDOMAINS_ENABLED: JSON.stringify(process.env.SUBDOMAINS_ENABLED)
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user