Skip to content

Commit

Permalink
Now exceptions thrown shows the Zephir file where they were generated…
Browse files Browse the repository at this point in the history
… (2)
  • Loading branch information
phalcon committed Apr 2, 2014
1 parent aa09356 commit 0582a27
Show file tree
Hide file tree
Showing 7 changed files with 28 additions and 28 deletions.
2 changes: 1 addition & 1 deletion Library/Statements/ThrowStatement.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ public function compile(CompilationContext $compilationContext)
if ($compilationContext->compiler->isClass($className)) {
$classDefinition = $compilationContext->compiler->getClassDefinition($className);
$message = $expr['parameters'][0]['parameter']['value'];
$codePrinter->output('ZEPHIR_THROW_EXCEPTION_DEBUG_STR(' . $classDefinition->getClassEntry() . ', "' . Utils::addSlashes($message) . '", "' . Compiler::getShortUserPath($statement['file']) . '", ' . $statement['line'] . ');');
$codePrinter->output('ZEPHIR_THROW_EXCEPTION_DEBUG_STR(' . $classDefinition->getClassEntry() . ', "' . Utils::addSlashes($message) . '", "' . Compiler::getShortUserPath($statement['expr']['file']) . '", ' . $statement['expr']['line'] . ');');
$codePrinter->output('return;');
return;
} else {
Expand Down
2 changes: 1 addition & 1 deletion Library/StaticCall.php
Original file line number Diff line number Diff line change
Expand Up @@ -574,7 +574,7 @@ public function compile(Expression $expr, CompilationContext $compilationContext
}

if ($callNumberParameters < $expectedNumberParameters) {
throw new CompilerException("Method '" . $classDefinition->getCompleteName() . "::" . $expression['name'] . "' called with a wrong number of parameters, the method has: " . $expectedNumberParameters . ", passed: " . $callNumberParameters, $expression);
throw new CompilerException("Method '" . $classDefinition->getCompleteName() . "::" . $expression['name'] . "' called with a wrong number of parameters, the method has: " . $expectedNumberParameters . ", passed: " . $callNumberParameters, $expression);
}
} else {

Expand Down
8 changes: 4 additions & 4 deletions ext/test/exceptions.c
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ ZEPHIR_INIT_CLASS(Test_Exceptions) {
PHP_METHOD(Test_Exceptions, testException1) {


ZEPHIR_THROW_EXCEPTION_DEBUG_STRW(test_exception_ce, "hello1", "test/exceptions.zep", 9);
ZEPHIR_THROW_EXCEPTION_DEBUG_STRW(test_exception_ce, "hello1", "test/exceptions.zep", 8);
return;

}
Expand All @@ -46,7 +46,7 @@ PHP_METHOD(Test_Exceptions, testException2) {
object_init_ex(_0, test_exception_ce);
ZEPHIR_CALL_METHOD(NULL, _0, "__construct", NULL, msg);
zephir_check_call_status();
zephir_throw_exception(_0 TSRMLS_CC);
zephir_throw_exception_debug(_0, "test/exceptions.zep", 15 TSRMLS_CC);
ZEPHIR_MM_RESTORE();
return;

Expand All @@ -65,7 +65,7 @@ PHP_METHOD(Test_Exceptions, testException3) {
object_init_ex(ex, test_exception_ce);
ZEPHIR_CALL_METHOD(NULL, ex, "__construct", NULL, msg);
zephir_check_call_status();
zephir_throw_exception(ex TSRMLS_CC);
zephir_throw_exception_debug(ex, "test/exceptions.zep", 23 TSRMLS_CC);
ZEPHIR_MM_RESTORE();
return;

Expand Down Expand Up @@ -97,7 +97,7 @@ PHP_METHOD(Test_Exceptions, testException4) {

ZEPHIR_CALL_METHOD(&_0, this_ptr, "getexception", NULL);
zephir_check_call_status();
zephir_throw_exception(_0 TSRMLS_CC);
zephir_throw_exception_debug(_0, "test/exceptions.zep", 33 TSRMLS_CC);
ZEPHIR_MM_RESTORE();
return;

Expand Down
2 changes: 1 addition & 1 deletion ext/test/fortytwo.c
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,7 @@ PHP_METHOD(Test_FortyTwo, proof) {
}
}
if (j != 42) {
ZEPHIR_THROW_EXCEPTION_DEBUG_STR(test_exception_ce, "not true", "test/fortytwo.zep", 30);
ZEPHIR_THROW_EXCEPTION_DEBUG_STR(test_exception_ce, "not true", "test/fortytwo.zep", 29);
return;
}
}
Expand Down
14 changes: 7 additions & 7 deletions ext/test/router.c
Original file line number Diff line number Diff line change
Expand Up @@ -366,7 +366,7 @@ PHP_METHOD(Test_Router, setDefaults) {


if (Z_TYPE_P(defaults) == IS_ARRAY) {
ZEPHIR_THROW_EXCEPTION_DEBUG_STRW(test_router_exception_ce, "Defaults must be an array", "test/router.zep", 248);
ZEPHIR_THROW_EXCEPTION_DEBUG_STRW(test_router_exception_ce, "Defaults must be an array", "test/router.zep", 247);
return;
}
if (zephir_array_isset_string_fetch(&namespaceName, defaults, SS("namespace"), 1 TSRMLS_CC)) {
Expand Down Expand Up @@ -473,7 +473,7 @@ PHP_METHOD(Test_Router, handle) {
_4 = zephir_fetch_nproperty_this(this_ptr, SL("_dependencyInjector"), PH_NOISY_CC);
ZEPHIR_CPY_WRT(dependencyInjector, _4);
if (Z_TYPE_P(dependencyInjector) != IS_OBJECT) {
ZEPHIR_THROW_EXCEPTION_DEBUG_STR(test_router_exception_ce, "A dependency injection container is required to access the 'request' service", "test/router.zep", 344);
ZEPHIR_THROW_EXCEPTION_DEBUG_STR(test_router_exception_ce, "A dependency injection container is required to access the 'request' service", "test/router.zep", 343);
return;
}
ZEPHIR_INIT_NVAR(_5);
Expand All @@ -495,7 +495,7 @@ PHP_METHOD(Test_Router, handle) {
ZEPHIR_OBS_NVAR(dependencyInjector);
zephir_read_property_this(&dependencyInjector, this_ptr, SL("_dependencyInjector"), PH_NOISY_CC);
if (Z_TYPE_P(dependencyInjector) != IS_OBJECT) {
ZEPHIR_THROW_EXCEPTION_DEBUG_STR(test_router_exception_ce, "A dependency injection container is required to access the 'request' service", "test/router.zep", 365);
ZEPHIR_THROW_EXCEPTION_DEBUG_STR(test_router_exception_ce, "A dependency injection container is required to access the 'request' service", "test/router.zep", 364);
return;
}
ZEPHIR_INIT_NVAR(_5);
Expand Down Expand Up @@ -544,7 +544,7 @@ PHP_METHOD(Test_Router, handle) {
zephir_check_call_status();
if (Z_TYPE_P(beforeMatch) != IS_NULL) {
if (zephir_is_callable(beforeMatch TSRMLS_CC)) {
ZEPHIR_THROW_EXCEPTION_DEBUG_STR(test_router_exception_ce, "Before-Match callback is not callable in matched route", "test/router.zep", 415);
ZEPHIR_THROW_EXCEPTION_DEBUG_STR(test_router_exception_ce, "Before-Match callback is not callable in matched route", "test/router.zep", 414);
return;
}
}
Expand Down Expand Up @@ -933,13 +933,13 @@ PHP_METHOD(Test_Router, mount) {


if (Z_TYPE_P(group) != IS_OBJECT) {
ZEPHIR_THROW_EXCEPTION_DEBUG_STR(test_router_exception_ce, "The group of routes is not valid", "test/router.zep", 679);
ZEPHIR_THROW_EXCEPTION_DEBUG_STR(test_router_exception_ce, "The group of routes is not valid", "test/router.zep", 678);
return;
}
ZEPHIR_CALL_METHOD(&groupRoutes, group, "getroutes", NULL);
zephir_check_call_status();
if (!(zephir_fast_count_int(groupRoutes TSRMLS_CC))) {
ZEPHIR_THROW_EXCEPTION_DEBUG_STR(test_router_exception_ce, "The group of routes does not contain any routes", "test/router.zep", 684);
ZEPHIR_THROW_EXCEPTION_DEBUG_STR(test_router_exception_ce, "The group of routes does not contain any routes", "test/router.zep", 683);
return;
}
ZEPHIR_CALL_METHOD(&beforeMatch, group, "getbeforematch", NULL);
Expand Down Expand Up @@ -997,7 +997,7 @@ PHP_METHOD(Test_Router, notFound) {

if (Z_TYPE_P(paths) != IS_ARRAY) {
if (Z_TYPE_P(paths) != IS_STRING) {
ZEPHIR_THROW_EXCEPTION_DEBUG_STRW(test_router_exception_ce, "The not-found paths must be an array or string", "test/router.zep", 726);
ZEPHIR_THROW_EXCEPTION_DEBUG_STRW(test_router_exception_ce, "The not-found paths must be an array or string", "test/router.zep", 725);
return;
}
}
Expand Down
4 changes: 2 additions & 2 deletions ext/test/router/route.c
Original file line number Diff line number Diff line change
Expand Up @@ -420,7 +420,7 @@ PHP_METHOD(Test_Router_Route, reConfigure) {


if (Z_TYPE_P(pattern) != IS_STRING) {
ZEPHIR_THROW_EXCEPTION_DEBUG_STR(test_router_exception_ce, "The pattern must be string", "test/router/route.zep", 271);
ZEPHIR_THROW_EXCEPTION_DEBUG_STR(test_router_exception_ce, "The pattern must be string", "test/router/route.zep", 270);
return;
}
if (Z_TYPE_P(paths) != IS_NULL) {
Expand Down Expand Up @@ -490,7 +490,7 @@ PHP_METHOD(Test_Router_Route, reConfigure) {
array_init(routePaths);
}
if (Z_TYPE_P(routePaths) != IS_ARRAY) {
ZEPHIR_THROW_EXCEPTION_DEBUG_STR(test_router_exception_ce, "The route contains invalid paths", "test/router/route.zep", 343);
ZEPHIR_THROW_EXCEPTION_DEBUG_STR(test_router_exception_ce, "The route contains invalid paths", "test/router/route.zep", 342);
return;
}
if (!(zephir_start_with_str(pattern, SL("#")))) {
Expand Down
24 changes: 12 additions & 12 deletions ext/test/trytest.c
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ PHP_METHOD(Test_TryTest, testThrow2) {
object_init_ex(_0, zend_exception_get_default(TSRMLS_C));
ZEPHIR_CALL_METHOD(NULL, _0, "__construct", NULL, message);
zephir_check_call_status();
zephir_throw_exception(_0 TSRMLS_CC);
zephir_throw_exception_debug(_0, "test/trytest.zep", 16 TSRMLS_CC);
ZEPHIR_MM_RESTORE();
return;

Expand Down Expand Up @@ -84,7 +84,7 @@ PHP_METHOD(Test_TryTest, testTry2) {
ZEPHIR_CALL_METHOD(NULL, _0, "__construct", NULL, _1);
zephir_check_temp_parameter(_1);
zephir_check_call_status_or_jump(try_end_1);
zephir_throw_exception(_0 TSRMLS_CC);
zephir_throw_exception_debug(_0, "test/trytest.zep", 27 TSRMLS_CC);
goto try_end_1;


Expand Down Expand Up @@ -112,7 +112,7 @@ PHP_METHOD(Test_TryTest, testTry3) {
ZEPHIR_CALL_METHOD(NULL, _0, "__construct", NULL, _1);
zephir_check_temp_parameter(_1);
zephir_check_call_status_or_jump(try_end_1);
zephir_throw_exception(_0 TSRMLS_CC);
zephir_throw_exception_debug(_0, "test/trytest.zep", 34 TSRMLS_CC);
goto try_end_1;


Expand Down Expand Up @@ -151,7 +151,7 @@ PHP_METHOD(Test_TryTest, testTry4) {
ZEPHIR_CALL_METHOD(NULL, _0, "__construct", NULL, _1);
zephir_check_temp_parameter(_1);
zephir_check_call_status_or_jump(try_end_1);
zephir_throw_exception(_0 TSRMLS_CC);
zephir_throw_exception_debug(_0, "test/trytest.zep", 46 TSRMLS_CC);
goto try_end_1;

} else {
Expand All @@ -162,7 +162,7 @@ PHP_METHOD(Test_TryTest, testTry4) {
ZEPHIR_CALL_METHOD(NULL, _0, "__construct", NULL, _1);
zephir_check_temp_parameter(_1);
zephir_check_call_status_or_jump(try_end_1);
zephir_throw_exception(_0 TSRMLS_CC);
zephir_throw_exception_debug(_0, "test/trytest.zep", 48 TSRMLS_CC);
goto try_end_1;

}
Expand Down Expand Up @@ -208,7 +208,7 @@ PHP_METHOD(Test_TryTest, testTry5) {
ZEPHIR_CALL_METHOD(NULL, _0, "__construct", NULL, _1);
zephir_check_temp_parameter(_1);
zephir_check_call_status_or_jump(try_end_1);
zephir_throw_exception(_0 TSRMLS_CC);
zephir_throw_exception_debug(_0, "test/trytest.zep", 63 TSRMLS_CC);
goto try_end_1;

} else {
Expand All @@ -219,7 +219,7 @@ PHP_METHOD(Test_TryTest, testTry5) {
ZEPHIR_CALL_METHOD(NULL, _0, "__construct", NULL, _1);
zephir_check_temp_parameter(_1);
zephir_check_call_status_or_jump(try_end_1);
zephir_throw_exception(_0 TSRMLS_CC);
zephir_throw_exception_debug(_0, "test/trytest.zep", 65 TSRMLS_CC);
goto try_end_1;

}
Expand Down Expand Up @@ -263,7 +263,7 @@ PHP_METHOD(Test_TryTest, testTry6) {
ZEPHIR_CALL_METHOD(NULL, _0, "__construct", NULL, _1);
zephir_check_temp_parameter(_1);
zephir_check_call_status_or_jump(try_end_1);
zephir_throw_exception(_0 TSRMLS_CC);
zephir_throw_exception_debug(_0, "test/trytest.zep", 80 TSRMLS_CC);
goto try_end_1;

} else {
Expand All @@ -274,7 +274,7 @@ PHP_METHOD(Test_TryTest, testTry6) {
ZEPHIR_CALL_METHOD(NULL, _0, "__construct", NULL, _1);
zephir_check_temp_parameter(_1);
zephir_check_call_status_or_jump(try_end_1);
zephir_throw_exception(_0 TSRMLS_CC);
zephir_throw_exception_debug(_0, "test/trytest.zep", 82 TSRMLS_CC);
goto try_end_1;

}
Expand Down Expand Up @@ -318,7 +318,7 @@ PHP_METHOD(Test_TryTest, testTry7) {
ZEPHIR_CALL_METHOD(NULL, _0, "__construct", NULL, _1);
zephir_check_temp_parameter(_1);
zephir_check_call_status_or_jump(try_end_1);
zephir_throw_exception(_0 TSRMLS_CC);
zephir_throw_exception_debug(_0, "test/trytest.zep", 99 TSRMLS_CC);
goto try_end_1;

} else {
Expand All @@ -329,7 +329,7 @@ PHP_METHOD(Test_TryTest, testTry7) {
ZEPHIR_CALL_METHOD(NULL, _0, "__construct", NULL, _1);
zephir_check_temp_parameter(_1);
zephir_check_call_status_or_jump(try_end_1);
zephir_throw_exception(_0 TSRMLS_CC);
zephir_throw_exception_debug(_0, "test/trytest.zep", 101 TSRMLS_CC);
goto try_end_1;

}
Expand Down Expand Up @@ -366,7 +366,7 @@ PHP_METHOD(Test_TryTest, testTry8) {
ZEPHIR_CALL_METHOD(NULL, _0, "__construct", NULL, _1);
zephir_check_temp_parameter(_1);
zephir_check_call_status_or_jump(try_end_1);
zephir_throw_exception(_0 TSRMLS_CC);
zephir_throw_exception_debug(_0, "test/trytest.zep", 111 TSRMLS_CC);
goto try_end_1;


Expand Down

0 comments on commit 0582a27

Please sign in to comment.