Skip to content

Commit f08a935

Browse files
Merge pull request #27 from hirohitokato/improve_throw
Improve throw statement
2 parents ae04ba1 + b7b91bc commit f08a935

File tree

3 files changed

+8
-8
lines changed

3 files changed

+8
-8
lines changed

dist/angular-workers.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -58,10 +58,10 @@ angular.module('FredrikSandell.worker-pool', []).service('WorkerService', [
5858
that.createAngularWorker = function (depFuncList) {
5959
//validate the input
6060
if (!Array.isArray(depFuncList) || depFuncList.length < 3 || typeof depFuncList[depFuncList.length - 1] !== 'function') {
61-
throw 'Input needs to be: [\'input\',\'output\'/*optional additional dependencies*/,\n' + ' function(workerInput, deferredOutput /*optional additional dependencies*/)\n' + ' {/*worker body*/}' + ']';
61+
throw new Error('Input needs to be: [\'input\',\'output\'/*optional additional dependencies*/,\n' + ' function(workerInput, deferredOutput /*optional additional dependencies*/)\n' + ' {/*worker body*/}' + ']');
6262
}
6363
if (typeof urlToAngular !== 'string') {
64-
throw 'The url to angular must be defined before worker creation';
64+
throw new Error('The url to angular must be defined before worker creation');
6565
}
6666
var deferred = $q.defer();
6767
var dependencyMetaData = createDependencyMetaData(extractDependencyList(depFuncList));
@@ -123,7 +123,7 @@ angular.module('FredrikSandell.worker-pool', []).service('WorkerService', [
123123
initializedWorker.addEventListener('message', function (e) {
124124
var eventId = e.data.event;
125125
if (eventId === 'initDone') {
126-
throw 'Received worker initialization in run method. This should already have occurred!';
126+
throw new Error('Received worker initialization in run method. This should already have occurred!');
127127
} else if (eventId === 'success') {
128128
deferred.resolve(e.data.data);
129129
} else if (eventId === 'failure') {

dist/angular-workers.min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/angular-workers.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -66,13 +66,13 @@ angular.module('FredrikSandell.worker-pool', [])
6666
if (!Array.isArray(depFuncList) ||
6767
depFuncList.length < 3 ||
6868
typeof depFuncList[depFuncList.length - 1] !== 'function') {
69-
throw 'Input needs to be: [\'input\',\'output\'\/*optional additional dependencies*\/,\n' +
69+
throw new Error('Input needs to be: [\'input\',\'output\'\/*optional additional dependencies*\/,\n' +
7070
' function(workerInput, deferredOutput \/*optional additional dependencies*\/)\n' +
7171
' {\/*worker body*\/}' +
72-
']';
72+
']');
7373
}
7474
if(typeof urlToAngular !== 'string') {
75-
throw 'The url to angular must be defined before worker creation';
75+
throw new Error('The url to angular must be defined before worker creation');
7676
}
7777
var deferred = $q.defer();
7878

@@ -156,7 +156,7 @@ angular.module('FredrikSandell.worker-pool', [])
156156
initializedWorker.addEventListener('message', function (e) {
157157
var eventId = e.data.event;
158158
if (eventId === 'initDone') {
159-
throw 'Received worker initialization in run method. This should already have occurred!';
159+
throw new Error('Received worker initialization in run method. This should already have occurred!');
160160
} else if (eventId === 'success') {
161161
deferred.resolve(e.data.data);
162162
} else if (eventId === 'failure') {

0 commit comments

Comments
 (0)