Ori.livneh has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/183153

Change subject: Use mw.format() to format error messages
......................................................................

Use mw.format() to format error messages

Depends on I87f62ac47 in core.

Change-Id: I5d59cfe24fc0281acc73514605bb8631ad91bd39
---
M modules/ext.eventLogging.core.js
1 file changed, 11 insertions(+), 5 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/EventLogging 
refs/changes/53/183153/1

diff --git a/modules/ext.eventLogging.core.js b/modules/ext.eventLogging.core.js
index 0e0b164..631d925 100644
--- a/modules/ext.eventLogging.core.js
+++ b/modules/ext.eventLogging.core.js
@@ -120,7 +120,7 @@
 
                        for ( key in obj ) {
                                if ( !schema.properties.hasOwnProperty( key ) ) 
{
-                                       errors.push( 'Undeclared property "' + 
key + '"' );
+                                       errors.push( mw.format( 'Undeclared 
property "$1"', key ) );
                                }
                        }
 
@@ -129,19 +129,25 @@
 
                                if ( !obj.hasOwnProperty( key ) ) {
                                        if ( prop.required ) {
-                                               errors.push( 'Missing property 
"' + key + '"' );
+                                               errors.push( mw.format( 
'Missing property "$1"', key ) );
                                        }
                                        continue;
                                }
                                val = obj[ key ];
 
                                if ( !( self.isInstanceOf( val, prop.type ) ) ) 
{
-                                       errors.push( 'Value ' + JSON.stringify( 
val ) + ' is the wrong type for property "' + key + '" (' + prop.type + ' 
expected)' );
+                                       errors.push( mw.format(
+                                               'Value $1 is the wrong type for 
property "$2" ($3 expected)',
+                                               JSON.stringify( val ), key, 
prop.type
+                                       ) );
                                        continue;
                                }
 
                                if ( prop[ 'enum' ] && $.inArray( val, prop[ 
'enum' ] ) === -1 ) {
-                                       errors.push( 'Value ' + JSON.stringify( 
val ) + ' for property "' + key + '" is not one of ' + JSON.stringify( 
prop['enum'] ) );
+                                       errors.push( mw.format(
+                                               'Value $1 for property "$2" is 
not one of $3',
+                                               JSON.stringify( val ), key, 
JSON.stringify( prop['enum'] )
+                                       ) );
                                }
                        }
 
@@ -181,7 +187,7 @@
                                valid = !errors.length;
 
                        while ( errors.length ) {
-                               mw.track( 'eventlogging.error', '[' + 
schemaName + '] ' + errors.pop() );
+                               mw.track( 'eventlogging.error', mw.format( 
'[$1] $2', schemaName, errors.pop() ) );
                        }
 
                        return {

-- 
To view, visit https://gerrit.wikimedia.org/r/183153
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I5d59cfe24fc0281acc73514605bb8631ad91bd39
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/EventLogging
Gerrit-Branch: master
Gerrit-Owner: Ori.livneh <[email protected]>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to