com php-src: Update exception error messages: Zend/zend_excep tions.c Zend/zend_interfaces.c
| From: | Anatol Belski | Date: | Mon, 15 Jun 2015 03:43:11 +0000 |
| Subject: | com php-src: Update exception error messages: Zend/zend_excep tions.c Zend/zend_interfaces.c | ||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-87333@lists.php.net to get a copy of this message | ||
Commit: 4d590ac35a3a68b8b453cd9bbf3f1300c2507d87
Author: Aaron Piotrowski <aaron@trowski.com> Sun, 14 Jun 2015 22:43:11 -0500
Parents: 110e0a5a2cda3bfa7778bb871502ff2b50e59f76
Branches: master
Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=4d590ac35a3a68b8b453cd9bbf3f1300c2507d87
Log:
Update exception error messages
Changed paths:
M Zend/zend_exceptions.c
M Zend/zend_interfaces..c
Diff:
diff --git a/Zend/zend_exceptions.c b/Zend/zend_exceptions.c
index ae55c1f..2a3152a 100644
--- a/Zend/zend_exceptions.c
+++ b/Zend/zend_exceptions.c
@@ -53,7 +53,7 @@ void zend_exception_set_previous(zend_object *exception, zend_object *add_previo
}
ZVAL_OBJ(&tmp, add_previous);
if (!instanceof_function(Z_OBJCE(tmp), zend_ce_throwable)) {
- zend_error_noreturn(E_CORE_ERROR, "Cannot set non exception as previous exception");
+ zend_error_noreturn(E_CORE_ERROR, "Previous exception must implement Throwable");
return;
}
ZVAL_OBJ(&zv, exception);
@@ -215,7 +215,7 @@ ZEND_METHOD(exception, __clone)
}
/* }}} */
-/* {{{ proto Exception::__construct(string message, int code [, Exception previous])
+/* {{{ proto Exception::__construct(string message, int code [, Throwable previous])
Exception constructor */
ZEND_METHOD(exception, __construct)
{
@@ -229,7 +229,7 @@ ZEND_METHOD(exception, __construct)
base_ce = zend_get_exception_base(object);
if (zend_parse_parameters_ex(ZEND_PARSE_PARAMS_QUIET, argc, "|SlO!", &message,
&code, &previous, base_ce) == FAILURE) {
- zend_error(E_EXCEPTION | E_ERROR, "Wrong parameters for Exception([string $exception [, long
$code [, Exception $previous = NULL]]])");
+ zend_error(E_EXCEPTION | E_ERROR, "Wrong parameters for %s([string $message [, long $code [,
Throwable $previous = NULL]]])", base_ce->name->val);
return;
}
@@ -247,7 +247,7 @@ ZEND_METHOD(exception, __construct)
}
/* }}} */
-/* {{{ proto ErrorException::__construct(string message, int code, int severity [, string filename
[, int lineno [, Exception previous]]])
+/* {{{ proto ErrorException::__construct(string message, int code, int severity [, string filename
[, int lineno [, Throwable previous]]])
ErrorException constructor */
ZEND_METHOD(error_exception, __construct)
{
@@ -258,7 +258,7 @@ ZEND_METHOD(error_exception, __construct)
size_t message_len, filename_len;
if (zend_parse_parameters_ex(ZEND_PARSE_PARAMS_QUIET, argc, "|sllslO!", &message,
&message_len, &code, &severity, &filename, &filename_len, &lineno,
&previous, default_exception_ce) == FAILURE) {
- zend_error(E_EXCEPTION | E_ERROR, "Wrong parameters for ErrorException([string $exception [,
long $code, [ long $severity, [ string $filename, [ long $lineno [, Exception $previous =
NULL]]]]]])");
+ zend_error(E_EXCEPTION | E_ERROR, "Wrong parameters for ErrorException([string $message [,
long $code, [ long $severity, [ string $filename, [ long $lineno [, Throwable $previous =
NULL]]]]]])");
return;
}
@@ -761,14 +761,14 @@ void zend_register_default_exception(void) /* {{{ */
zend_class_entry ce;
zend_property_info *prop;
+ memcpy(&default_exception_handlers, zend_get_std_object_handlers(),
sizeof(zend_object_handlers));
+ default_exception_handlers.clone_obj = NULL;
+
INIT_CLASS_ENTRY(ce, "Exception", default_exception_functions);
default_exception_ce = zend_register_internal_class_ex(&ce, NULL);
default_exception_ce->create_object = zend_default_exception_new;
zend_class_implements(default_exception_ce, 1, zend_ce_throwable);
- memcpy(&default_exception_handlers, zend_get_std_object_handlers(),
sizeof(zend_object_handlers));
- default_exception_handlers.clone_obj = NULL;
-
zend_declare_property_string(default_exception_ce, "message",
sizeof("message")-1, "", ZEND_ACC_PROTECTED);
zend_declare_property_string(default_exception_ce, "string",
sizeof("string")-1, "", ZEND_ACC_PRIVATE);
zend_declare_property_long(default_exception_ce, "code", sizeof("code")-1, 0,
ZEND_ACC_PROTECTED);
diff --git a/Zend/zend_interfaces.c b/Zend/zend_interfaces.c
index 3d8398d..e5b2d3f 100644
--- a/Zend/zend_interfaces.c
+++ b/Zend/zend_interfaces.c
@@ -509,9 +509,11 @@ static int zend_implement_throwable(zend_class_entry *interface,
zend_class_entr
if (instanceof_function(class_type, zend_exception_get_default()) ||
instanceof_function(class_type, zend_get_error())) {
return SUCCESS;
}
- zend_error_noreturn(E_CORE_ERROR, "Class %s cannot implement interface %s, extend Exception
or Error instead",
+ zend_error_noreturn(E_ERROR, "Class %s cannot implement interface %s, extend %s or %s
instead",
class_type->name->val,
- interface->name->val);
+ interface->name->val,
+ zend_exception_get_default()->name->val,
+ zend_get_error()->name->val);
return FAILURE;
}
/* }}} */