Merge remote branch 'weaverryan/kernel_controller_exception_message'
* weaverryan/kernel_controller_exception_message: [HttpKernel] Making the "no response returned from controller" more explanatory when it's possible that the user forgot a return statement in his/her controller
This commit is contained in:
commit
5ebfb300bd
@ -120,7 +120,13 @@ class HttpKernel implements HttpKernelInterface
|
||||
}
|
||||
|
||||
if (!$response instanceof Response) {
|
||||
throw new \LogicException(sprintf('The controller must return a response (%s given).', $this->varToString($response)));
|
||||
$msg = sprintf('The controller must return a response (%s given).', $this->varToString($response));
|
||||
|
||||
// the user may have forgotten to return something
|
||||
if (null === $response) {
|
||||
$msg .= ' Did you forget to add a return statement somewhere in your controller?';
|
||||
}
|
||||
throw new \LogicException($msg);
|
||||
}
|
||||
}
|
||||
|
||||
@ -187,6 +193,10 @@ class HttpKernel implements HttpKernelInterface
|
||||
return '[resource]';
|
||||
}
|
||||
|
||||
if (null === $var) {
|
||||
return 'null';
|
||||
}
|
||||
|
||||
return str_replace("\n", '', var_export((string) $var, true));
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user