Constantin Kaplinsky | 47ed8d3 | 2004-10-08 09:43:57 +0000 | [diff] [blame^] | 1 | /* Copyright (C) 2002-2003 RealVNC Ltd. All Rights Reserved. |
| 2 | * |
| 3 | * This is free software; you can redistribute it and/or modify |
| 4 | * it under the terms of the GNU General Public License as published by |
| 5 | * the Free Software Foundation; either version 2 of the License, or |
| 6 | * (at your option) any later version. |
| 7 | * |
| 8 | * This software is distributed in the hope that it will be useful, |
| 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 11 | * GNU General Public License for more details. |
| 12 | * |
| 13 | * You should have received a copy of the GNU General Public License |
| 14 | * along with this software; if not, write to the Free Software |
| 15 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, |
| 16 | * USA. |
| 17 | */ |
| 18 | |
| 19 | #ifndef __RDR_EXCEPTION_H__ |
| 20 | #define __RDR_EXCEPTION_H__ |
| 21 | |
| 22 | #include <stdio.h> |
| 23 | #include <string.h> |
| 24 | |
| 25 | namespace rdr { |
| 26 | |
| 27 | struct Exception { |
| 28 | enum { len = 256 }; |
| 29 | char str_[len]; |
| 30 | char type_[len]; |
| 31 | Exception(const char* s=0, const char* e="rdr::Exception") { |
| 32 | str_[0] = 0; |
| 33 | if (s) |
| 34 | strncat(str_, s, len-1); |
| 35 | else |
| 36 | strcat(str_, "Exception"); |
| 37 | type_[0] = 0; |
| 38 | strncat(type_, e, len-1); |
| 39 | } |
| 40 | virtual const char* str() const { return str_; } |
| 41 | virtual const char* type() const { return type_; } |
| 42 | }; |
| 43 | |
| 44 | struct SystemException : public Exception { |
| 45 | int err; |
| 46 | SystemException(const char* s, int err_); |
| 47 | }; |
| 48 | |
| 49 | struct TimedOut : public Exception { |
| 50 | TimedOut(const char* s="Timed out") : Exception(s,"rdr::TimedOut") {} |
| 51 | }; |
| 52 | |
| 53 | struct EndOfStream : public Exception { |
| 54 | EndOfStream(const char* s="End of stream") |
| 55 | : Exception(s,"rdr::EndOfStream") {} |
| 56 | }; |
| 57 | } |
| 58 | |
| 59 | #endif |