|
| 1 | +#pragma once |
| 2 | + |
| 3 | +#include <cmath> |
| 4 | +using namespace std; |
| 5 | + |
| 6 | +#include <Zend/zend.h> |
| 7 | +#include <Zend/zend_exceptions.h> |
| 8 | +#include <Zend/zend_API.h> |
| 9 | + |
| 10 | +#define ARANGODB_THROW(ex, message) zend_throw_exception_ex(ex, 0, message, __FILE__, __LINE__); |
| 11 | + |
| 12 | + |
| 13 | +namespace arangodb { namespace fuerte { namespace php { |
| 14 | + |
| 15 | + static zend_class_entry* _RuntimeException; |
| 16 | + static zend_class_entry* _InvalidOptionException; |
| 17 | + |
| 18 | + |
| 19 | + static zend_class_entry* RuntimeException() { |
| 20 | + zend_string *exceptionClassName = zend_string_tolower(zend_string_init(ZEND_STRL("ArangoDb\\RuntimeException"), 1)); |
| 21 | + zend_class_entry *exceptionClass = static_cast<zend_class_entry*>(zend_hash_find_ptr(CG(class_table), exceptionClassName)); |
| 22 | + zend_string_release(exceptionClassName); |
| 23 | + |
| 24 | + return exceptionClass; |
| 25 | + } |
| 26 | + |
| 27 | + static zend_class_entry* InvalidOptionException() { |
| 28 | + zend_string *exceptionClassName = zend_string_tolower(zend_string_init(ZEND_STRL("ArangoDb\\InvalidOptionException"), 1)); |
| 29 | + zend_class_entry *exceptionClass = static_cast<zend_class_entry*>(zend_hash_find_ptr(CG(class_table), exceptionClassName)); |
| 30 | + zend_string_release(exceptionClassName); |
| 31 | + |
| 32 | + return exceptionClass; |
| 33 | + } |
| 34 | + |
| 35 | + |
| 36 | + static void registerRuntimeException() |
| 37 | + { |
| 38 | + zend_class_entry ce; |
| 39 | + INIT_CLASS_ENTRY(ce, "ArangoDb\\RuntimeException", NULL); |
| 40 | + _RuntimeException = zend_register_internal_class_ex(&ce, zend_exception_get_default()); |
| 41 | + } |
| 42 | + |
| 43 | + static void registerInvalidOptionException() |
| 44 | + { |
| 45 | + zend_class_entry ce; |
| 46 | + INIT_CLASS_ENTRY(ce, "ArangoDb\\InvalidOptionException", NULL); |
| 47 | + _InvalidOptionException = zend_register_internal_class_ex(&ce, _RuntimeException); |
| 48 | + } |
| 49 | + |
| 50 | + static void registerCustomExceptions() |
| 51 | + { |
| 52 | + registerRuntimeException(); |
| 53 | + registerInvalidOptionException(); |
| 54 | + } |
| 55 | + |
| 56 | +}}} |
0 commit comments