// CatalogError.h #ifndef CatalogError_H #define CatalogError_H // David Adams // November 2004 // // Error codes and messages for catalogs. #include namespace dset { class CatalogError { public: // typedefs typedef int Status; private: // data // Type of object. std::string m_objtype; public: // static methods // Error code for errors. static Status no_error() { return 0; } // Error code for an attempt to insert an invalid object. static Status invalid_object_error() { return 1; } // Error code for an attempt to insert a dataset whose ID is // already allocated. static Status id_assigned_error() { return 2; } // Error code for an attempt to insert a null dataset. static Status null_object_error() { return 3; } // Error code for an attempt to retrieve with an invalid ID. static Status invalid_id_error() { return 4; } // Error code for an ID that is not registered in the repository. static Status no_such_object_error() { return 5; } // Error code for failure reading the underlying catalog. // Returned for operations not requiring write access. static Status generic_read_error() { return 6; } // Error code for failure writing the underlying datalog. // Returned for any operation requiring write access. static Status generic_write_error() { return 7; } // Error code for failure accessing the underlying catalog. // Error code for attempt by subclass to set a reserved error static Status generic_access_error() { return 8; } // Error code for an attempt to insert or retrieve with a // local ID. static Status local_id_error() { return 9; } // Error code if object XML cannot be parsed. static Status object_parse_error() { return 12; } // Error code if object creation fails. static Status object_create_error() { return 13; } // Error code if object creation fails. static Status unknown_error() { return 20; } // Error code for an attempt to retrive a dataset with an ID // Return if an error code is generic, i.e. reserved to this class. static bool is_generic_error(int ecode) { return ecode >= 0 && ecode <= 20; } public: // constructors and destructor // Constructor. // Argument appears in error messages. Expected values are // ID, dataset, job, .... CatalogError(std::string objtype); // Return the string describing an error. std::string message(int ecode); }; } // end namespace dset #endif