/* * Jakelib2 - General purpose C++ library * Copyright (C) 2001 Florian Wolff (florian@donuz.de) * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * This library 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 * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * * $Id: ZException.h,v 1.2 2002/06/08 10:09:42 florian Exp $ */ #define MAX_EXCEPTION_TEXT 256 #include /*****************************************************************************\ | Exception | \*****************************************************************************/ class ZException { protected: char text[MAX_EXCEPTION_TEXT + 50]; char reason[MAX_EXCEPTION_TEXT]; int errorCode; public: ZException(ZString& msg) { strcpy(reason, ": "); strcat(reason, msg.getChars()); errorCode = 0; }; ZException(const char* msg) { strcpy(reason, ": "); strcat(reason, msg); errorCode = 0; }; ZException() { strcpy(reason, ""); errorCode = 0; }; virtual ~ZException() { }; int GetErrorCode() { return errorCode; } virtual const char* getChars() { strcpy(text, getClassname()); strcat(text, reason); return text; } virtual const char* getClassname() { return "ZException"; }; }; /*****************************************************************************\ | ZIndexOutOfBoundsException | \*****************************************************************************/ class ZIndexOutOfBoundsException : public ZException { public: ZIndexOutOfBoundsException(ZString& msg) : ZException(msg) {}; ZIndexOutOfBoundsException(const char* msg) : ZException(msg) {}; ZIndexOutOfBoundsException() : ZException() {}; const char* getClassname() { return "ZIndexOutOfBoundsException"; }; }; /*****************************************************************************\ | ZArrayIndexOutOfBoundsException | \*****************************************************************************/ class ZArrayIndexOutOfBoundsException : public ZIndexOutOfBoundsException { public: ZArrayIndexOutOfBoundsException(ZString& msg) : ZIndexOutOfBoundsException(msg) {}; ZArrayIndexOutOfBoundsException(const char* msg) : ZIndexOutOfBoundsException(msg) {}; const char* getClassname() { return "ZArrayIndexOutOfBoundsException"; }; }; /*****************************************************************************\ | ZIllegalArgumentException | \*****************************************************************************/ class ZIllegalArgumentException : public ZException { public: ZIllegalArgumentException(ZString& msg) : ZException(msg) {}; ZIllegalArgumentException(const char* msg) : ZException(msg) {}; const char* getClassname() { return "ZIllegalArgumentException"; }; }; /*****************************************************************************\ | ZMemoryException | \*****************************************************************************/ class ZMemoryException : public ZException { public: ZMemoryException(ZString& msg) : ZException(msg) {}; ZMemoryException(const char* msg) : ZException(msg) {}; const char* getClassname() { return "ZMemoryException"; }; }; /*****************************************************************************\ | ZIOException | \*****************************************************************************/ class ZIOException : public ZException { public: ZIOException(ZString& msg) : ZException(msg) {}; ZIOException(const char* msg) : ZException(msg) {}; const char* getClassname() { return "ZIOException"; }; }; /*****************************************************************************\ | ZFileNotFoundException | \*****************************************************************************/ class ZFileNotFoundException : public ZIOException { public: ZFileNotFoundException(ZString& msg) : ZIOException(msg) {}; ZFileNotFoundException(const char* msg) : ZIOException(msg) {}; ZFileNotFoundException(ZString& msg, ZString& reason) : ZIOException(ZString(0, "%S (%S)", &msg, &reason).getChars()) {}; const char* getClassname() { return "ZFileNotFoundException"; }; }; /*****************************************************************************\ | ZNullPointerException | \*****************************************************************************/ class ZNullPointerException : public ZException { public: ZNullPointerException(const char* msg) : ZException(msg) {}; ZNullPointerException() : ZException() {}; const char* getClassname() { return "ZNullPointerException"; }; }; /*****************************************************************************\ | ZThreadException | \*****************************************************************************/ class ZThreadException : public ZException { public: ZThreadException() : ZException() {}; ZThreadException(const char* msg) : ZException(msg) {}; const char* getClassname() { return "ZThreadException"; }; }; /*****************************************************************************\ | ZIllegalThreadStateException | \*****************************************************************************/ class ZIllegalThreadStateException : public ZThreadException { public: ZIllegalThreadStateException() : ZThreadException() {}; ZIllegalThreadStateException(const char* msg) : ZThreadException(msg) {}; const char* getClassname() { return "ZIllegalThreadStateException"; }; }; /*****************************************************************************\ | ZMalformedURLException | \*****************************************************************************/ class ZMalformedURLException : public ZException { public: ZMalformedURLException() : ZException() {}; ZMalformedURLException(const char* msg) : ZException(msg) {}; const char* getClassname() { return "ZMalformedURLException"; }; }; /*****************************************************************************\ | ZUnsupportedOperationException | \*****************************************************************************/ class ZUnsupportedOperationException : public ZException { public: ZUnsupportedOperationException() : ZException() {}; ZUnsupportedOperationException(const char* msg) : ZException(msg) {}; const char* getClassname() { return "ZUnsupportedOperationException"; }; }; /*****************************************************************************\ | ZNoSuchElementException | \*****************************************************************************/ class ZNoSuchElementException : public ZException { public: ZNoSuchElementException() : ZException() {}; ZNoSuchElementException(const char* msg) : ZException(msg) {}; const char* getClassname() { return "ZNoSuchElementException"; }; }; /*****************************************************************************\ | ZNumberFormatException | \*****************************************************************************/ class ZNumberFormatException : public ZException { public: ZNumberFormatException() : ZException() {}; ZNumberFormatException(const char* msg) : ZException(msg) {}; const char* getClassname() { return "ZNumberFormatException"; }; };