You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

Exception.h 1.6KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. /* Copyright (C) 2002-2005 RealVNC Ltd. All Rights Reserved.
  2. * Copyright (C) 2004 Red Hat Inc.
  3. * Copyright (C) 2010 TigerVNC Team
  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. #ifndef __RDR_EXCEPTION_H__
  21. #define __RDR_EXCEPTION_H__
  22. #ifdef __GNUC__
  23. # define __printf_attr(a, b) __attribute__((__format__ (__printf__, a, b)))
  24. #else
  25. # define __printf_attr(a, b)
  26. #endif // __GNUC__
  27. namespace rdr {
  28. struct Exception {
  29. enum { len = 256 };
  30. char str_[len];
  31. Exception(const char *format = 0, ...) __printf_attr(2, 3);
  32. virtual ~Exception() {}
  33. virtual const char* str() const { return str_; }
  34. };
  35. struct SystemException : public Exception {
  36. int err;
  37. SystemException(const char* s, int err_);
  38. };
  39. struct GAIException : public Exception {
  40. int err;
  41. GAIException(const char* s, int err_);
  42. };
  43. struct EndOfStream : public Exception {
  44. EndOfStream() : Exception("End of stream") {}
  45. };
  46. }
  47. #endif