Anonymous user
Module:String: Difference between revisions
accommodate the commonly used "no_category" function
Enwikipedia>Dragons flight (improves commenting, adds whitespace and error handling to sub, improvements to error handling generally.) |
Enwikipedia>Dragons flight (accommodate the commonly used "no_category" function) |
||
Line 15:
error_category: If an error occurs, specifies the name of a category to
include with the error message. The default category is
[Category:Errors reported by Module String].
no_category: If set to
is generated.
]]
Line 80 ⟶ 82:
if j < 0 then
j = len + j + 1;
▲ end
if j < i then▼
return str._error( 'String subset indices out of order' );▼
end
if i > len or j > len or i < 1 or j < 1 then
return str._error( 'String subset index out of range' );
end
▲ if j < i then
▲ return str._error( 'String subset indices out of order' );
end
Line 299 ⟶ 301:
local error_category = frame.args.error_category or 'Errors reported by Module String';
local ignore_errors = frame.args.ignore_errors or false;
local no_category = frame.args.no_category or false;
if str._getBoolean(ignore_errors) then
Line 305 ⟶ 308:
local error_str = '<strong class="error">String Module Error: ' .. error_str .. '</strong>';
if error_category ~= '' and not str._getBoolean( no_category ) then
error_str = '[[Category:' .. error_category .. ']]' .. error_str;
end
Line 320 ⟶ 323:
if type( boolean_str ) == 'string' then
boolean_str = boolean_str:lower();
if boolean_str == 'false' or boolean_str == 'no' or boolean_str == '0'
or boolean_str == '' then
boolean_value = false;
else
|