blob: 1b92f7778e5d11ba2584f85606c83f645c4cdcd3 [file] [log] [blame]
Constantin Kaplinskya2adc8d2006-05-25 05:01:55 +00001/* Copyright (C) 2002-2005 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
25namespace rdr {
26
27 struct Exception {
28 enum { len = 256 };
29 char str_[len];
30 Exception(const char* s=0) {
31 str_[0] = 0;
32 if (s)
33 strncat(str_, s, len-1);
34 else
35 strcat(str_, "Exception");
36 }
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 {
46 TimedOut(const char* s="Timed out") : Exception(s) {}
47 };
48
49 struct EndOfStream : public Exception {
50 EndOfStream(const char* s="End of stream") : Exception(s) {}
51 };
52
53 struct FrameException : public Exception {
54 FrameException(const char* s="Frame exception") : Exception(s) {}
55 };
56}
57
58#endif