aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorLibravatar Vijay A <avijayr@protonmail.com>2021-08-21 21:58:58 +0530
committerLibravatar Vijay A <avijayr@protonmail.com>2021-08-21 21:58:58 +0530
commit4cbf03cb5ad0981606682a2b23dbcfcfb18e4e52 (patch)
tree14f1b501eb5e0de88365c02fd375dc816a37c4a2 /src
parentstyle: consistent syntax style [skip ci] (diff)
downloadferdium-app-4cbf03cb5ad0981606682a2b23dbcfcfb18e4e52.tar.gz
ferdium-app-4cbf03cb5ad0981606682a2b23dbcfcfb18e4e52.tar.zst
ferdium-app-4cbf03cb5ad0981606682a2b23dbcfcfb18e4e52.zip
refactor: fail quickly if the initialization data is incorrect
Diffstat (limited to 'src')
-rw-r--r--src/models/Recipe.ts8
-rw-r--r--src/models/Service.js8
2 files changed, 5 insertions, 11 deletions
diff --git a/src/models/Recipe.ts b/src/models/Recipe.ts
index 33d383983..0a93fbc5a 100644
--- a/src/models/Recipe.ts
+++ b/src/models/Recipe.ts
@@ -76,12 +76,8 @@ export default class Recipe {
76 throw Error(`Recipe '${data.name}' requires Id`); 76 throw Error(`Recipe '${data.name}' requires Id`);
77 } 77 }
78 78
79 try { 79 if (!semver.valid(data.version)) {
80 if (!semver.valid(data.version)) { 80 throw Error(`Version ${data.version} of recipe '${data.name}' is not a valid semver version`);
81 throw Error(`Version ${data.version} of recipe '${data.name}' is not a valid semver version`);
82 }
83 } catch (e) {
84 console.warn(e.message);
85 } 81 }
86 82
87 this.id = data.id || this.id; 83 this.id = data.id || this.id;
diff --git a/src/models/Service.js b/src/models/Service.js
index c2b081864..4b78b9a40 100644
--- a/src/models/Service.js
+++ b/src/models/Service.js
@@ -14,7 +14,7 @@ const debug = require('debug')('Ferdi:Service');
14export default class Service { 14export default class Service {
15 id = ''; 15 id = '';
16 16
17 recipe = ''; 17 recipe = null;
18 18
19 _webview = null; 19 _webview = null;
20 20
@@ -94,13 +94,11 @@ export default class Service {
94 94
95 constructor(data, recipe) { 95 constructor(data, recipe) {
96 if (!data) { 96 if (!data) {
97 console.error('Service config not valid'); 97 throw Error('Service config not valid');
98 return null;
99 } 98 }
100 99
101 if (!recipe) { 100 if (!recipe) {
102 console.error('Service recipe not valid'); 101 throw Error('Service recipe not valid');
103 return null;
104 } 102 }
105 103
106 this.userAgentModel = new UserAgent(recipe.overrideUserAgent); 104 this.userAgentModel = new UserAgent(recipe.overrideUserAgent);