summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorJanito Vaqueiro Ferreira Filho <janito@mullvad.net>2018-09-05 08:04:52 -0300
committerJanito Vaqueiro Ferreira Filho <janito@mullvad.net>2018-09-06 08:47:59 -0300
commite4e68e31f4c015718dc197c6d815710aad6ed7bf (patch)
tree1afa2d75c61f932dda8b159860784a103146d6e6
parent759a20aaebe2d460800472ac3b076f42c81b65c9 (diff)
downloadmullvadvpn-e4e68e31f4c015718dc197c6d815710aad6ed7bf.tar.xz
mullvadvpn-e4e68e31f4c015718dc197c6d815710aad6ed7bf.zip
Add function to build `BlockedError` message
-rw-r--r--gui/packages/desktop/src/renderer/errors.js37
1 files changed, 18 insertions, 19 deletions
diff --git a/gui/packages/desktop/src/renderer/errors.js b/gui/packages/desktop/src/renderer/errors.js
index 9cbf63808a..32ec75b105 100644
--- a/gui/packages/desktop/src/renderer/errors.js
+++ b/gui/packages/desktop/src/renderer/errors.js
@@ -4,25 +4,24 @@ import type { BlockReason } from './lib/daemon-rpc';
export class BlockedError extends Error {
constructor(reason: BlockReason) {
- switch (reason) {
- case 'enable_ipv6_error':
- super('Could not configure IPv6, please enable it on your system or disable it in the app');
- break;
- case 'set_security_policy_error':
- super('Failed to apply security policy');
- break;
- case 'start_tunnel_error':
- super('Failed to start tunnel connection');
- break;
- case 'no_matching_relay':
- super('No relay server matches the current settings');
- break;
- case 'no_account_token':
- super('No account token configured');
- break;
- default:
- super(`Unknown error: ${(reason: empty)}`);
- }
+ const message = (function() {
+ switch (reason) {
+ case 'enable_ipv6_error':
+ return 'Could not configure IPv6, please enable it on your system or disable it in the app';
+ case 'set_security_policy_error':
+ return 'Failed to apply security policy';
+ case 'start_tunnel_error':
+ return 'Failed to start tunnel connection';
+ case 'no_matching_relay':
+ return 'No relay server matches the current settings';
+ case 'no_account_token':
+ return 'No account token configured';
+ default:
+ return `Unknown error: ${(reason: empty)}`;
+ }
+ })();
+
+ super(message);
}
}