- /* =============================================================================
- * scpp_exception.cpp
- * Copyright (c) 2003 - 2013 Nomura Kei
- * LICENSE :
- * LGPL (GNU Lesser General General Public License - Version 3,29 June 2007)
- * http://www.gnu.org/copyleft/lesser.html
- * =============================================================================
- *
- * Java ライクな Exception を扱うモジュール
- *
- */
- #include <scpp_errno.hpp>
- #include <scpp_exception.hpp>
- namespace scpp
- {
- ////////////////////////////////////////////////////////////////////////////////
- //
- // Throwable
- //
- /**
- * 最後に発生した errno に対応するメッセージをもつ Throwable を構築します.
- * エラーメッセージを取得できない場合, 空文字がメッセージに設定されます.
- */
- Throwable::Throwable() throw() : message("")
- {
- int errnum = Errno::getError();
- Errno::getErrorMessage(&this->message, errnum);
- }
- /**
- * コピーコンストラクタ.
- *
- * @param t コピー元
- */
- Throwable::Throwable(const Throwable& t) throw() : message(t.message)
- {
- // NOP
- }
- /**
- * 指定されたメッセージを持つ Throwable を構築します.
- *
- * @param msg メッセージ
- */
- Throwable::Throwable(const std::string& msg) throw() : message(msg)
- {
- // NOP
- }
- /**
- * デストラクタ.
- */
- Throwable::~Throwable() throw()
- {
- // NOP
- }
- /**
- * エラーメッセージを返します.
- *
- * @return エラーメッセージ
- */
- const char* Throwable::what() const throw()
- {
- return message.c_str();
- }
- ////////////////////////////////////////////////////////////////////////////////
- //
- // Exception
- //
- /**
- * 最後に発生した errno に対応するメッセージをもつ Exception を構築します.
- * エラーメッセージを取得できない場合, 空文字がメッセージに設定されます.
- */
- Exception::Exception() throw() : Throwable()
- {
- }
- /**
- * コピーコンストラクタ.
- *
- * @param t コピー元
- */
- Exception::Exception(const Exception& t) throw() : Throwable(t)
- {
- // NOP
- }
- /**
- * 指定されたメッセージを持つ Exception を構築します.
- *
- * @param msg メッセージ
- */
- Exception::Exception(const std::string& msg) throw() : Throwable(msg)
- {
- // NOP
- }
- /**
- * デストラクタ.
- */
- Exception::~Exception() throw()
- {
- // NOP
- }
- ////////////////////////////////////////////////////////////////////////////////
- //
- // Error
- //
- /**
- * 最後に発生した errno に対応するメッセージをもつ Exception を構築します.
- * エラーメッセージを取得できない場合, 空文字がメッセージに設定されます.
- */
- Error::Error() throw() : Throwable()
- {
- // NOP
- }
- /**
- * コピーコンストラクタ.
- *
- * @param t コピー元
- */
- Error::Error(const Error& t) throw() : Throwable(t)
- {
- // NOP
- }
- /**
- * 指定されたメッセージを持つ Exception を構築します.
- *
- * @param msg メッセージ
- */
- Error::Error(const std::string& msg) throw() : Throwable(msg)
- {
- // NOP
- }
- /**
- * デストラクタ.
- */
- Error::~Error() throw()
- {
- // NOP
- }
- } // namespace scpp