summaryrefslogtreecommitdiffhomepage
path: root/app/components
diff options
context:
space:
mode:
authorJanito Vaqueiro Ferreira Filho <janito@mullvad.net>2018-06-13 16:03:05 -0300
committerJanito Vaqueiro Ferreira Filho <janito@mullvad.net>2018-06-15 08:49:42 -0300
commit47454b7fe8341997e2580811e4aed00084fb741c (patch)
tree4532087665b22ec76a9170f0addefe7026467e4b /app/components
parentffc9500d5d57c427378591aab5e4c86960d27fe7 (diff)
downloadmullvadvpn-47454b7fe8341997e2580811e4aed00084fb741c.tar.xz
mullvadvpn-47454b7fe8341997e2580811e4aed00084fb741c.zip
Split `BackendError` into individual error classes
Diffstat (limited to 'app/components')
-rw-r--r--app/components/Connect.js17
1 files changed, 10 insertions, 7 deletions
diff --git a/app/components/Connect.js b/app/components/Connect.js
index 3fbe04cefa..f4647678f1 100644
--- a/app/components/Connect.js
+++ b/app/components/Connect.js
@@ -9,7 +9,7 @@ import { TransparentButton, RedTransparentButton, GreenButton, Label } from './s
import Accordion from './Accordion';
import styles from './ConnectStyles';
-import { BackendError } from '../lib/backend';
+import { NoCreditError, NoInternetError } from '../lib/backend';
import Map from './Map';
import type { HeaderBarStyle } from './HeaderBar';
@@ -79,15 +79,18 @@ export default class Connect extends Component<ConnectProps, ConnectState> {
);
}
- renderError(error: BackendError) {
+ renderError(error: Error) {
+ const title = error.userFriendlyTitle || 'Something went wrong';
+ const message = error.userFriendlyMessage || error.message;
+
return (
<View style={styles.connect}>
<View style={styles.status_icon}>
<Img source="icon-fail" height={60} width={60} alt="" />
</View>
<View style={styles.status}>
- <View style={styles.error_title}>{error.title}</View>
- <View style={styles.error_message}>{error.message}</View>
+ <View style={styles.error_title}>{title}</View>
+ <View style={styles.error_message}>{message}</View>
{error.type === 'NO_CREDIT' ? (
<View>
<GreenButton onPress={this.onExternalLink.bind(this, 'purchase')}>
@@ -339,16 +342,16 @@ export default class Connect extends Component<ConnectProps, ConnectState> {
return classes;
}
- displayError(): ?BackendError {
+ displayError(): ?Error {
// Offline?
if (!this.props.connection.isOnline) {
- return new BackendError('NO_INTERNET');
+ return new NoInternetError();
}
// No credit?
const expiry = this.props.accountExpiry;
if (expiry && moment(expiry).isSameOrBefore(moment())) {
- return new BackendError('NO_CREDIT');
+ return new NoCreditError();
}
return null;