Error Code Description Variables -- Handy & Cool!

Posted by 1of10 on Sat 15 Mar 2003 07:19 AM — 1 posts, 11,977 views.

Canada #0
For people who want a description of the error code being returned by various functions.

Place the following associative array in your script files. Best place is a global script that is included in seperate script files, thus making it available to all without duplication. This is why I love using PerlScript :) At the top of all individual script files require the global one.

require "C:/Program Files/MUclient/scripts/GLOBAL.pl";


If you want to swap single quotes for qouble quotes in the array below, make sure you remember to escape the proper characters! Single quotes do not require escaping.

# ----------------------------------------------------------
# Error codes returned by various functions
# ----------------------------------------------------------
%errCodes = (
	0 => 'Success!',
	30001 => 'World already open.',
	30002 => 'World closed; cannot perform action.',
	30003 => 'Name required; none specified.',
	30004 => 'Sound file cannot be played.',
	30005 => 'Trigger does not exist.',
	30006 => 'Trigger already exists.',
	30007 => 'Trigger "match" text cannot be empty.',
	30008 => 'Object name invalid.',
	30009 => 'Script name/subroutine not in script file.',
	30010 => 'Alias does not exist.',
	30011 => 'Alias already exists.',
	30012 => 'Alias "match" text cannot be empty.',
	30013 => 'Cannot open file.',
	30014 => 'Log file not open.',
	30015 => 'Log file already open.',
	30016 => 'Bad write to log file.',
	30017 => 'Timer does not exist.',
	30018 => 'Timer already exists.',
	30019 => 'Cannot delete variable; not found.',
	30020 => 'SetCommand: Command window not empty.',
	30021 => 'Regular expression syntax error.',
	30022 => 'AddTimer: Invalid time given.',
	30023 => 'AddToMapper: Invalid direction.',
	30024 => 'No items in mapper.',
	30025 => 'Unknown option name.',
	30026 => 'New option value out of range.',
	30027 => 'Trigger sequence value invalid.',
	30028 => 'Trigger "send to" is invalid.',
	30029 => 'Trigger label not specified/invalid for "send to variable".',
	30030 => 'Plugin file not found.',
	30031 => 'Parsing or other problem loading plugin.',
	30032 => 'Plugin cannot set option.',
	30033 => 'Plugin cannot get option.',
	30034 => 'Requested plugin not valid.',
	30035 => 'Only plugins can do this.',
	30036 => 'Plugin script name/subroutine not in plugin script.',
	30037 => 'Plugin does not support save state.',
	30038 => 'Plugin cannot save state.  No state directory?',
	30039 => 'Plugin is disabled.',
	30040 => 'Cannot call plugin routine.'
);


Then to use the new descriptions:

my($return) = $world->deleteVariable("TestVar");
$world->note("DeleteVariable failed: $errCodes{$return}") if ($return);


If all is okay, $return will equal zero, and the note will not show. If you want to see all return values whether success or fail, remove the if ($return) so the note always gets printed.

NOTE: $errCodes{$return} is correct! So is %errCodes{$return}, but Perl run with -w (warnings enabled) will complain and say to use $errCodes instead.