diff options
author | Emiel Bruijntjes <emiel.bruijntjes@copernica.com> | 2014-08-26 13:08:39 +0200 |
---|---|---|
committer | Emiel Bruijntjes <emiel.bruijntjes@copernica.com> | 2014-08-26 13:08:39 +0200 |
commit | f526c4c7a7ada1ab534ca0976c7b66718b9a5660 (patch) | |
tree | 68b4db309ee00d3b7ebc1743b4825057b3db7f28 /include/fatalerror.h | |
parent | a286c34777e48d59410e7511f52f4a6f08000ba3 (diff) | |
parent | 97bc6757346d394a4b7d5898983be298e0b0ea98 (diff) |
fixed conflict
Diffstat (limited to 'include/fatalerror.h')
-rw-r--r-- | include/fatalerror.h | 66 |
1 files changed, 66 insertions, 0 deletions
diff --git a/include/fatalerror.h b/include/fatalerror.h new file mode 100644 index 0000000..b178f25 --- /dev/null +++ b/include/fatalerror.h @@ -0,0 +1,66 @@ +/** + * FatalError.h + * + * + * Normally, fatal errors are reported with a call to zend_error(). + * + * However, this will trigger a longjmp(), which will cause objects + * constructed in the extension not to be destructed. We use therefore + * this FatalError class, which is a normally exception that _does_ + * cause objects to be destructed. + * + * When it is caught, right before control is handed back to the Zend + * engine, it will turn the exception into a zend_error() call and + * thus a longjmp. + * + * @author Emiel Bruijntjes <emiel.bruijntjes@copernica.com> + * @copyright 2014 Copernica BV + */ + +/** + * Set up namespace + */ +namespace Php { + +/** + * Class definition + */ +class FatalError : public Exception +{ +public: + /** + * Constructor + * @param message + */ + FatalError(const std::string &message) : Exception(message) {} + + /** + * Destructor + */ + virtual ~FatalError() throw() + { + } + + /** + * Is this a native exception (one that was thrown from C++ code) + * @return bool + */ + virtual bool native() const + { + // although it is native, we return 0 because it should not persist + // as exception, but it should live on as zend_error() in stead + return false; + } + + /** + * Report this error as a fatal error + * @return bool + */ + virtual bool report() const override; +}; + +/** + * End of namespace + */ +} + |