Esanders has uploaded a new change for review. (
https://gerrit.wikimedia.org/r/351597 )
Change subject: Code lint: Throw errors, no strings
......................................................................
Code lint: Throw errors, no strings
Change-Id: I4bb4de96a5e61b67b7a4c8f16a22f67f53cb034f
---
M resources/mmv/logging/mmv.logging.DurationLogger.js
M resources/mmv/mmv.HtmlUtils.js
M resources/mmv/mmv.ThumbnailWidthCalculator.js
M resources/mmv/mmv.js
M resources/mmv/model/mmv.model.EmbedFileInfo.js
M resources/mmv/model/mmv.model.Image.js
M resources/mmv/model/mmv.model.License.js
M resources/mmv/model/mmv.model.TaskQueue.js
M resources/mmv/model/mmv.model.Thumbnail.js
M resources/mmv/model/mmv.model.ThumbnailWidth.js
M resources/mmv/routing/mmv.routing.Router.js
M resources/mmv/routing/mmv.routing.ThumbnailRoute.js
M tests/qunit/mmv/logging/mmv.logging.PerformanceLogger.test.js
13 files changed, 16 insertions(+), 16 deletions(-)
git pull
ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/MultimediaViewer
refs/changes/97/351597/1
diff --git a/resources/mmv/logging/mmv.logging.DurationLogger.js
b/resources/mmv/logging/mmv.logging.DurationLogger.js
index 726eaa5..d2e0f91 100644
--- a/resources/mmv/logging/mmv.logging.DurationLogger.js
+++ b/resources/mmv/logging/mmv.logging.DurationLogger.js
@@ -63,7 +63,7 @@
start = $.now();
if ( !typeOrTypes ) {
- throw 'Must specify type';
+ throw new Error( 'Must specify type' );
}
if ( !$.isArray( typeOrTypes ) ) {
@@ -92,7 +92,7 @@
var stop = $.now();
if ( !type ) {
- throw 'Must specify type';
+ throw new Error( 'Must specify type' );
}
// Don't overwrite an existing value
@@ -120,7 +120,7 @@
var e, duration;
if ( !type ) {
- throw 'Must specify type';
+ throw new Error( 'Must specify type' );
}
if ( !this.starts.hasOwnProperty( type ) || this.starts[ type ]
=== undefined ) {
diff --git a/resources/mmv/mmv.HtmlUtils.js b/resources/mmv/mmv.HtmlUtils.js
index fd9610d..c3fffdc 100644
--- a/resources/mmv/mmv.HtmlUtils.js
+++ b/resources/mmv/mmv.HtmlUtils.js
@@ -55,7 +55,7 @@
return $( '<div>' + html + '</div>' );
} else {
mw.log.warn( 'wrapAndJquerify: unknown type', html );
- throw 'wrapAndJquerify: unknown type';
+ throw new Error( 'wrapAndJquerify: unknown type' );
}
};
diff --git a/resources/mmv/mmv.ThumbnailWidthCalculator.js
b/resources/mmv/mmv.ThumbnailWidthCalculator.js
index 7f856be..2087aa4 100644
--- a/resources/mmv/mmv.ThumbnailWidthCalculator.js
+++ b/resources/mmv/mmv.ThumbnailWidthCalculator.js
@@ -40,7 +40,7 @@
options = $.extend( {}, this.defaultOptions, options );
if ( !options.widthBuckets.length ) {
- throw 'No buckets!';
+ throw new Error( 'No buckets!' );
}
/**
diff --git a/resources/mmv/mmv.js b/resources/mmv/mmv.js
index f7b2eee..876e419 100644
--- a/resources/mmv/mmv.js
+++ b/resources/mmv/mmv.js
@@ -469,7 +469,7 @@
if ( recursion ) {
// this should not be possible, but an infinite
recursion is nasty
// business, so we make a sanity check
- throw 'MediaViewer internal error:
displayPlaceholderThumbnail recursion';
+ throw new Error( 'MediaViewer internal error:
displayPlaceholderThumbnail recursion' );
}
this.imageInfoProvider.get( image.filePageTitle ).done(
function ( imageInfo ) {
// Make sure the user has not navigated away
while we were waiting for the size
diff --git a/resources/mmv/model/mmv.model.EmbedFileInfo.js
b/resources/mmv/model/mmv.model.EmbedFileInfo.js
index 69844d6..3e5378d 100644
--- a/resources/mmv/model/mmv.model.EmbedFileInfo.js
+++ b/resources/mmv/model/mmv.model.EmbedFileInfo.js
@@ -33,7 +33,7 @@
alt
) {
if ( !imageInfo || !repoInfo ) {
- throw 'imageInfo and repoInfo are required and must
have a value';
+ throw new Error( 'imageInfo and repoInfo are required
and must have a value' );
}
/** @property {mw.mmv.model.Image} imageInfo The title of the
file */
diff --git a/resources/mmv/model/mmv.model.Image.js
b/resources/mmv/model/mmv.model.Image.js
index 27ad16f..03cf44e 100644
--- a/resources/mmv/model/mmv.model.Image.js
+++ b/resources/mmv/model/mmv.model.Image.js
@@ -297,7 +297,7 @@
} else if ( type === 'list' ) {
return value === '' ? [] : value.split( '|' );
} else {
- throw 'mw.mmv.model.Image.parseExtmeta: unknown type';
+ throw new Error( 'mw.mmv.model.Image.parseExtmeta:
unknown type' );
}
};
diff --git a/resources/mmv/model/mmv.model.License.js
b/resources/mmv/model/mmv.model.License.js
index ab09c07..2e60809 100644
--- a/resources/mmv/model/mmv.model.License.js
+++ b/resources/mmv/model/mmv.model.License.js
@@ -40,7 +40,7 @@
nonFree
) {
if ( !shortName ) {
- throw 'mw.mmv.model.License: shortName is required';
+ throw new Error( 'mw.mmv.model.License: shortName is
required' );
}
/** @property {string} shortName short (abbreviated) name of
the license (e.g. CC-BY-SA-3.0) */
diff --git a/resources/mmv/model/mmv.model.TaskQueue.js
b/resources/mmv/model/mmv.model.TaskQueue.js
index 7ae6d6a..bfa908b 100644
--- a/resources/mmv/model/mmv.model.TaskQueue.js
+++ b/resources/mmv/model/mmv.model.TaskQueue.js
@@ -61,7 +61,7 @@
*/
tqp.push = function ( task ) {
if ( this.state !== TaskQueue.State.NOT_STARTED ) {
- throw 'Task queue already started!';
+ throw new Error( 'Task queue already started!' );
}
this.queue.push( task );
};
diff --git a/resources/mmv/model/mmv.model.Thumbnail.js
b/resources/mmv/model/mmv.model.Thumbnail.js
index 1685200..aef0576 100644
--- a/resources/mmv/model/mmv.model.Thumbnail.js
+++ b/resources/mmv/model/mmv.model.Thumbnail.js
@@ -31,7 +31,7 @@
height
) {
if ( !url || !width || !height ) {
- throw 'All parameters are required and cannot be empty
or zero';
+ throw new Error( 'All parameters are required and
cannot be empty or zero' );
}
/** @property {string} url The URL to the thumbnail */
diff --git a/resources/mmv/model/mmv.model.ThumbnailWidth.js
b/resources/mmv/model/mmv.model.ThumbnailWidth.js
index 0fc9f88..b23c0cc 100644
--- a/resources/mmv/model/mmv.model.ThumbnailWidth.js
+++ b/resources/mmv/model/mmv.model.ThumbnailWidth.js
@@ -32,7 +32,7 @@
*/
function ThumbnailWidth( cssWidth, cssHeight, screen, real ) {
if ( !cssWidth || !cssHeight || !screen || !real ) {
- throw 'All parameters are required and cannot be empty or zero';
+ throw new Error( 'All parameters are required and cannot be
empty or zero' );
}
/**
diff --git a/resources/mmv/routing/mmv.routing.Router.js
b/resources/mmv/routing/mmv.routing.Router.js
index f6993ac..093bbb6 100644
--- a/resources/mmv/routing/mmv.routing.Router.js
+++ b/resources/mmv/routing/mmv.routing.Router.js
@@ -87,9 +87,9 @@
} else if ( route instanceof mw.mmv.routing.MainFileRoute ) {
return this.applicationPrefix;
} else if ( route instanceof mw.mmv.routing.Route ) {
- throw 'mw.mmv.routing.Router.createHash: not
implemented for ' + route.constructor.name;
+ throw new Error( 'mw.mmv.routing.Router.createHash: not
implemented for ' + route.constructor.name );
} else {
- throw 'mw.mmv.routing.Router.createHash: invalid
argument';
+ throw new Error( 'mw.mmv.routing.Router.createHash:
invalid argument' );
}
};
diff --git a/resources/mmv/routing/mmv.routing.ThumbnailRoute.js
b/resources/mmv/routing/mmv.routing.ThumbnailRoute.js
index c7ac99b..328ad8c 100644
--- a/resources/mmv/routing/mmv.routing.ThumbnailRoute.js
+++ b/resources/mmv/routing/mmv.routing.ThumbnailRoute.js
@@ -27,7 +27,7 @@
*/
function ThumbnailRoute( fileTitle ) {
if ( !fileTitle ) {
- throw 'mw.mmv.routing.ThumbnailRoute: fileTitle
parameter is required';
+ throw new Error( 'mw.mmv.routing.ThumbnailRoute:
fileTitle parameter is required' );
}
this.fileTitle = fileTitle;
}
diff --git a/tests/qunit/mmv/logging/mmv.logging.PerformanceLogger.test.js
b/tests/qunit/mmv/logging/mmv.logging.PerformanceLogger.test.js
index 006f392..f24f366 100644
--- a/tests/qunit/mmv/logging/mmv.logging.PerformanceLogger.test.js
+++ b/tests/qunit/mmv/logging/mmv.logging.PerformanceLogger.test.js
@@ -288,7 +288,7 @@
url = 'http://example.com/',
performance = new mw.mmv.logging.PerformanceLogger();
- performance.newXHR = function () { throw 'XMLHttpRequest?
What\'s that?'; };
+ performance.newXHR = function () { throw new Error(
'XMLHttpRequest? What\'s that?' ); };
performance.record( type, url ).fail( function () {
assert.ok( true, 'the promise is rejected when
XMLHttpRequest is not supported' );
--
To view, visit https://gerrit.wikimedia.org/r/351597
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I4bb4de96a5e61b67b7a4c8f16a22f67f53cb034f
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/MultimediaViewer
Gerrit-Branch: master
Gerrit-Owner: Esanders <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits