#! python: #w#VIC errors.py module # # Copyright 2002, 2003 by Timothy Rue <3seas@threeseas.net> # # VIC errors.py module: version 0.5.1.python (BETA) # # # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License # as published by the Free Software Foundation version 2 # of the License. http://www.gnu.org/copyleft/gpl.html # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. # Or access http://www.gnu.org/copyleft/gpl.html ########################################################################## #August 29, 2003 made file IQ parseable 0.5.1 #July 24, 2003 initial release 0.5 # ########################################################################## """ #w#Error codes and descriptions """ #s#000 ok = 000 unknown_command = 001 wrong_arg_count = 002 incorrect_args = 003 #s#100 no_vic = 100 no_vic_by_name = 101 no_var = 102 rename_no_ext = 103 rename_failed = 104 delete_failed = 105 save_failed = 106 bad_field_count = 107 dir_no_exit = 108 file_no_exit = 109 bad_pk_file = 110 bad_oi_file = 111 invalid_ip = 112 invalid_op = 113 chdir_failed = 114 bad_sf_file = 115 bad_iq_file = 116 bad_id_file = 117 bad_ke_file = 118 bad_flags = 119 #s#200 set_var_failed = 200 #s#300 sh_failed = 300 #w#human_readable ### ### Given one of the above error codes, return the ### human-readable version of it ### #s#def getName def getName(err_code): base_errs = [ "No Error", "Unknown command", "Wrong number of arguments", "Incorrect arguments", ] vic_errs = [ "VIC Command, but no VIC focused", "Name/Id does not match a VIC", "Variable does not exist", "Rename out of extensions", "Failed to rename file", "Failed to delete file", "Failed to save file", "Invalid field-count for this type", "Given directory does not exist", "Given file does not exist", "Invalid PK file", "Invalid OI file", "Invalid Input parameters", "Invalid Output parameters", "Failed to change directory", "Invalid SF file", "Invalid IQ file", "Invalid ID file", "Invalid KE file", "Invalid Processing Flags", ] var_errs = [ "Error inputting to variable", ] sys_errs = [ "Shell Failed", ] if (err_code >=0 and err_code < len(base_errs)): return base_errs[err_code] if (err_code >= 100 and err_code < 200): err_code -= 100 return vic_errs[err_code] if (err_code >= 200 and err_code < 300): err_code -= 200 return var_errs[err_code] if (err_code >= 300 and err_code < 400): err_code -= 300 return sys_errs[err_code] return "Erroneous error code" # give up