Constantin Kaplinsky | a2adc8d | 2006-05-25 05:01:55 +0000 | [diff] [blame] | 1 | /* Copyright (C) 2002-2005 RealVNC Ltd. All Rights Reserved. |
Adam Tkac | 35e6d4c | 2010-04-23 14:12:18 +0000 | [diff] [blame] | 2 | * Copyright (C) 2004 Red Hat Inc. |
| 3 | * Copyright (C) 2010 TigerVNC Team |
Constantin Kaplinsky | a2adc8d | 2006-05-25 05:01:55 +0000 | [diff] [blame] | 4 | * |
| 5 | * This is free software; you can redistribute it and/or modify |
| 6 | * it under the terms of the GNU General Public License as published by |
| 7 | * the Free Software Foundation; either version 2 of the License, or |
| 8 | * (at your option) any later version. |
| 9 | * |
| 10 | * This software is distributed in the hope that it will be useful, |
| 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 13 | * GNU General Public License for more details. |
| 14 | * |
| 15 | * You should have received a copy of the GNU General Public License |
| 16 | * along with this software; if not, write to the Free Software |
| 17 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, |
| 18 | * USA. |
| 19 | */ |
| 20 | |
| 21 | #ifndef __RDR_EXCEPTION_H__ |
| 22 | #define __RDR_EXCEPTION_H__ |
| 23 | |
Pierre Ossman | 5b3c5f4 | 2015-03-03 16:11:26 +0100 | [diff] [blame] | 24 | #ifdef __GNUC__ |
| 25 | # define __printf_attr(a, b) __attribute__((__format__ (__printf__, a, b))) |
| 26 | #else |
| 27 | # define __printf_attr(a, b) |
| 28 | #endif // __GNUC__ |
| 29 | |
Constantin Kaplinsky | a2adc8d | 2006-05-25 05:01:55 +0000 | [diff] [blame] | 30 | namespace rdr { |
| 31 | |
| 32 | struct Exception { |
| 33 | enum { len = 256 }; |
| 34 | char str_[len]; |
Pierre Ossman | 5b3c5f4 | 2015-03-03 16:11:26 +0100 | [diff] [blame] | 35 | Exception(const char *format = 0, ...) __printf_attr(2, 3); |
Constantin Kaplinsky | a1958b7 | 2007-09-05 09:31:08 +0000 | [diff] [blame] | 36 | virtual ~Exception() {} |
Constantin Kaplinsky | a2adc8d | 2006-05-25 05:01:55 +0000 | [diff] [blame] | 37 | virtual const char* str() const { return str_; } |
| 38 | }; |
| 39 | |
| 40 | struct SystemException : public Exception { |
| 41 | int err; |
| 42 | SystemException(const char* s, int err_); |
| 43 | }; |
| 44 | |
| 45 | struct TimedOut : public Exception { |
Pierre Ossman | 1922550 | 2017-10-12 15:05:07 +0200 | [diff] [blame^] | 46 | TimedOut() : Exception("Timed out") {} |
Constantin Kaplinsky | a2adc8d | 2006-05-25 05:01:55 +0000 | [diff] [blame] | 47 | }; |
| 48 | |
| 49 | struct EndOfStream : public Exception { |
Pierre Ossman | 1922550 | 2017-10-12 15:05:07 +0200 | [diff] [blame^] | 50 | EndOfStream() : Exception("End of stream") {} |
Constantin Kaplinsky | a2adc8d | 2006-05-25 05:01:55 +0000 | [diff] [blame] | 51 | }; |
Adam Tkac | 35e6d4c | 2010-04-23 14:12:18 +0000 | [diff] [blame] | 52 | |
Constantin Kaplinsky | a2adc8d | 2006-05-25 05:01:55 +0000 | [diff] [blame] | 53 | } |
| 54 | |
| 55 | #endif |