Jeff Thompson | a92861a | 2013-10-16 14:06:23 -0700 | [diff] [blame] | 1 | /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil -*- */ |
| 2 | /** |
| 3 | * Copyright (C) 2013 Regents of the University of California. |
| 4 | * @author: Yingdi Yu <yingdi@cs.ucla.edu> |
| 5 | * @author: Jeff Thompson <jefft0@remap.ucla.edu> |
| 6 | * See COPYING for copyright and distribution information. |
| 7 | */ |
| 8 | |
| 9 | #ifndef NDN_DER_EXCEPTION_HPP |
| 10 | #define NDN_DER_EXCEPTION_HPP |
| 11 | |
| 12 | #include <exception> |
| 13 | #include <string> |
| 14 | |
| 15 | namespace ndn { |
| 16 | |
| 17 | namespace der { |
| 18 | |
| 19 | class DerException : public std::exception { |
| 20 | public: |
| 21 | DerException(const std::string& errorMessage) throw(); |
| 22 | |
| 23 | ~DerException() throw(); |
| 24 | |
| 25 | std::string Msg() { return errorMessage_; } |
| 26 | |
| 27 | virtual const char* what() const throw() { return errorMessage_.c_str(); } |
| 28 | |
| 29 | private: |
| 30 | const std::string errorMessage_; |
| 31 | }; |
| 32 | |
| 33 | class NegativeLengthException : public DerException |
| 34 | { |
| 35 | public: |
| 36 | NegativeLengthException(const std::string& errorMessage) |
| 37 | : DerException(errorMessage) |
| 38 | {} |
| 39 | }; |
| 40 | |
| 41 | class DerEncodingException : public DerException |
| 42 | { |
| 43 | public: |
| 44 | DerEncodingException(const std::string& errorMessage) |
| 45 | : DerException(errorMessage) |
| 46 | {} |
| 47 | }; |
| 48 | |
| 49 | class DerDecodingException : public DerException |
| 50 | { |
| 51 | public: |
| 52 | DerDecodingException(const std::string& errorMessage) |
| 53 | : DerException(errorMessage) |
| 54 | {} |
| 55 | }; |
| 56 | |
| 57 | } // der |
| 58 | |
| 59 | } |
| 60 | |
| 61 | #endif |