handling unknown status codes [CakeException] Unkn

2019-08-07 02:24发布

How would I handle gracefully failures of another http server i'm talking to via HttpSocket? Haven't been able to find any good examples

Stack Trace:
2014-02-01 07:00:35 Error: Fatal Error (256): [CakeException] Unknown status code
#0 /home/alterscape/lab/cakephp/lib/Cake/Error/ExceptionRenderer.php(212): CakeResponse-    >statusCode(110)
#1 [internal function]: ExceptionRenderer->error400(Object(SocketException))
#2 /home/alterscape/lab/cakephp/lib/Cake/Error/ExceptionRenderer.php(175): call_user_func_array(Array, Array)
#3 /home/alterscape/lab/cakephp/lib/Cake/Error/ErrorHandler.php(120): ExceptionRenderer->render()
#4 [internal function]: ErrorHandler::handleException(Object(SocketException))
#5 {main} in [/home/alterscape/lab/cakephp/lib/Cake/Error/ErrorHandler.php, line 129]

2014-02-01 07:00:35 Error: [InternalErrorException] Internal Server Error

StackTrace
#0 /home/alterscape/lab/cakephp/lib/Cake/Routing/Dispatcher.php(185): Controller->invokeAction(Object(CakeRequest))
#1 /home/alterscape/lab/cakephp/lib/Cake/Routing/Dispatcher.php(160): Dispatcher->_invoke(Object(SecurityLogsController), Object(CakeRequest), Object(CakeResponse))
#2 /home/alterscape/lab/cakephp/app/webroot/index.php(108): Dispatcher->dispatch(Object(CakeRequest), Object(CakeResponse))
#3 {main}
2014-02-01 07:00:35 Error: [SocketException] Connection timed out

1条回答
疯言疯语
2楼-- · 2019-08-07 03:04

The [CakeException] Unknown status code is caused because CakePHP doesn't recognize Error Code 110. Check out:

http://api.cakephp.org/2.3/source-class-CakeResponse.html#601-617

Here's a way to add your custom HTTP code to cake's approved list. I use this in AppController.

http://api.cakephp.org/2.3/class-CakeResponse.html#_httpCodes

查看更多
登录 后发表回答