Main Page | Class Hierarchy | Class List | Directories | File List | Class Members | File Members

exceptions.h

Go to the documentation of this file.
00001 /*!\file exceptions.h
00002         \brief Declerations for the exceptions thrown by
00003         any PackageManager class.*/
00004 
00005 #ifndef __EXCEPTIONS_H__
00006 #define __EXCEPTIONS_H__
00007 
00008 #include "pmstring.h"
00009 #include "dependency.h"
00010 #include "packageversion.h"
00011 
00012 //!Exception error codes.
00013 /*!Enum for all errorCodes supplied by PortageErrorCode. Check
00014   with the function that throws the exception to see if the
00015   message contains any useful information.*/
00016 enum PortageErrorCode
00017 {
00018         eNotEnoughMem,                  //!<New error - not enough memory for a new.
00019         eErrorOpeningFile,              //!<Cannot open a file.
00020         eFileStreamError,               //!<Error with a filestrem.
00021         eInvalidDescription,    //!<Invalid format of category/name-version string.
00022         eInvalidVariable,               //!<Invalid variable, not found in ConfigReader.
00023         eBadFormatOrDependency, //!<An || in a dependency string was not followed by a bracket.
00024         eNoResults,                             //!<Thrown if there are no results for the Search.
00025         eBadVersionCompare,             //!<Version compare could not come up with an answer - this is a bug.
00026         eEmptyVersionCompare,   //!<Empty string passed to version compare.
00027         eNoVirtualFound,                //!<No Virtual found for the string supplied.
00028         eVirtualUnavailable             //!<The virtual asked for was unavailable. Possibly masked?
00029 };
00030 
00031 //!The main exception class within Sportage.
00032 /*!The main exception class within Sportage. These can be thrown both
00033    as warnings and fatal errors, check the function to see if the error
00034    is fatal.*/
00035 struct PortageException
00036 {
00037         PortageException(PortageErrorCode code){errorCode = code;}      //!<Constructor setting up errorcode.
00038         ;
00039         PortageException(PortageErrorCode code, PMString message)       //!<Constructor setting up code and message.
00040         {
00041                 errorCode = code;
00042                 errorMessage = message;
00043         };
00044         
00045         PortageErrorCode errorCode;     //!<Error code.
00046         PMString errorMessage;          //!<Message - a useful string to go with the code. Check throwing function to see what it contains.
00047 };
00048 
00049 //!Exception thrown by directory readers.
00050 /*!Exception thrown by directory readers. The code is the one received from scandir.*/
00051 struct DirectoryException
00052 {
00053         DirectoryException(){};                                                 //!<Default constructor.
00054         DirectoryException(int code, PMString message)  //!<Constructor to set up the variables.
00055         {
00056                 errorCode = code;
00057                 errorMessage = message;
00058         };
00059         int errorCode;                  //!<Error code received from scanf.
00060         PMString errorMessage;  //!<Message - usually the directory that the error occured on.
00061 };
00062 
00063 //!Exception for dependency calculation.
00064 /*!Exception to say when things have gone wrong with dependencies. Usually
00065   the dependency of version cannot be met. Check with throwing functions however.*/
00066 struct DependencyException
00067 {
00068         DependencyException(Dependency passedDependency,PackageVersion passedVersion)   //!<Constructor.
00069         {
00070                 dependency = passedDependency;
00071                 version = passedVersion;
00072         };
00073         Dependency dependency;  //!<Dependency that cannot be met (usually).
00074         PackageVersion version; //!<Version who's dependency cannot be met (usually).
00075 };
00076 
00077 #endif

Generated on Wed May 25 15:29:54 2005 for Package Management System for Gentoo Linux by  doxygen 1.4.1