[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
Also made "null" show up as null in the exception message, instead of as a blank string (slightly more expressive).
This commit is contained in:
parent
6fe8884ad8
commit
80c102761c
@ -120,7 +120,13 @@ class HttpKernel implements HttpKernelInterface
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!$response instanceof Response) {
|
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]';
|
return '[resource]';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (null === $var) {
|
||||||
|
return 'null';
|
||||||
|
}
|
||||||
|
|
||||||
return str_replace("\n", '', var_export((string) $var, true));
|
return str_replace("\n", '', var_export((string) $var, true));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user