Jump to content

Module:Citation/CS1/Utilities: Difference between revisions

no edit summary
m>Trappist the monk
No edit summary
m>Trappist the monk
No edit summary
Line 58: Line 58:
end
end


return {is_set=is_set, in_array=in_array, substitute=substitute, error_comment=error_comment, z=z} -- return exported functions and tables
--[[--------------------------< S E T _ E R R O R >--------------------------------------------------------------
 
Sets an error condition and returns the appropriate error message.  The actual placement of the error message in the output is
the responsibility of the calling function.
 
]]
local function set_error( error_id, arguments, raw, prefix, suffix )
local error_state = cfg.error_conditions[ error_id ];
prefix = prefix or "";
suffix = suffix or "";
if error_state == nil then
error( cfg.messages['undefined_error'] );
elseif is_set( error_state.category ) then
table.insert( z.error_categories, error_state.category );
end
local message = substitute( error_state.message, arguments );
message = message .. " ([[" .. cfg.messages['help page link'] ..
"#" .. error_state.anchor .. "|" ..
cfg.messages['help page label'] .. "]])";
z.error_ids[ error_id ] = true;
if in_array( error_id, { 'bare_url_missing_title', 'trans_missing_title' } )
and z.error_ids['citation_missing_title'] then
return '', false;
end
message = table.concat({ prefix, message, suffix });
if raw == true then
return message, error_state.hidden;
end
return error_comment( message, error_state.hidden );
end
 
return { -- return exported functions and tables
is_set = is_set,
in_array = in_array,
substitute = substitute,
error_comment = error_comment,
set_error = set_error,
z = z,
}
Anonymous user
Cookies help us deliver our services. By using our services, you agree to our use of cookies.