Laravel 来自第 3 方库的异常未显示堆栈跟踪
Laravel exception from 3rd party library not showing stack trace
我在 Laravel 4 应用程序中使用 Bigcommerce PHP SDK。 Bigcommerce SDK 配置为在发生错误时抛出异常。这些异常通常是 class Bigcommerce\Api\ClientError
。当抛出这些异常时,我并没有像通常对 Laravel 异常所做的那样在我的错误日志中看到详细的输出(包括堆栈跟踪、行号、文件位置等),我只在错误中看到一行日志,像这样:
[2015-05-05 21:19:00] production.ERROR: Client Error (404): The requested resource was not found. [] []
我需要在我的应用程序中做些什么来确保使用与其他 Laravel 异常相同的详细信息记录这些 Bigcommerce 异常吗?
这是我在 Laravel 中经常看到的错误输出示例。此输出是 Bigcommerce\Api\NetworkError
的结果。我不明白为什么我要查找的是此类异常的输出,但 Bigcommerce\Api\ClientError
不是:
[2015-05-05 13:22:22] production.ERROR: exception 'Bigcommerce\Api\NetworkError' with message 'Empty reply from server' in /var/www/html/dev.example/vendor/bigcommerce/api/src/Bigcommerce/Api/Connection.php:213
Stack trace:
#0 /var/www/html/dev.example/vendor/bigcommerce/api/src/Bigcommerce/Api/Connection.php(326): Bigcommerce\Api\Connection->handleResponse()
#1 /var/www/html/dev.example/vendor/bigcommerce/api/src/Bigcommerce/Api/Client.php(225): Bigcommerce\Api\Connection->post('https://api.big...', Object(stdClass))
#2 /var/www/html/dev.example/vendor/bigcommerce/api/src/Bigcommerce/Api/Client.php(436): Bigcommerce\Api\Client::createResource('/products', Array)
#3 /var/www/html/dev.example/app/spire_models/Product.php(873): Bigcommerce\Api\Client::createProduct(Array)
#4 /var/www/html/dev.example/app/spire_models/Product.php(35): Spire_models\Product->pushToExternal()
#5 /var/www/html/dev.example/app/extensions/SlaveTrait.php(26): Spire_models\Product->additionalSyncWithMaster()
#6 /var/www/html/dev.example/app/controllers/ProductInfoController.php(225): Spire_models\Product->syncWithMaster()
#7 [internal function]: ProductInfoController->saveProductDetails()
#8 /var/www/html/dev.example/vendor/laravel/framework/src/Illuminate/Routing/Controller.php(231): call_user_func_array(Array, Array)
#9 /var/www/html/dev.example/vendor/laravel/framework/src/Illuminate/Routing/ControllerDispatcher.php(93): Illuminate\Routing\Controller->callAction('saveProductDeta...', Array)
#10 /var/www/html/dev.example/vendor/laravel/framework/src/Illuminate/Routing/ControllerDispatcher.php(62): Illuminate\Routing\ControllerDispatcher->call(Object(ProductInfoController), Object(Illuminate\Routing\Route), 'saveProductDeta...')
#11 /var/www/html/dev.example/vendor/laravel/framework/src/Illuminate/Routing/Router.php(967): Illuminate\Routing\ControllerDispatcher->dispatch(Object(Illuminate\Routing\Route), Object(Illuminate\Http\Request), 'ProductInfoCont...', 'saveProductDeta...')
#12 [internal function]: Illuminate\Routing\Router->Illuminate\Routing\{closure}()
#13 /var/www/html/dev.example/vendor/laravel/framework/src/Illuminate/Routing/Route.php(109): call_user_func_array(Object(Closure), Array)
#14 /var/www/html/dev.example/vendor/laravel/framework/src/Illuminate/Routing/Router.php(1033): Illuminate\Routing\Route->run(Object(Illuminate\Http\Request))
#15 /var/www/html/dev.example/vendor/laravel/framework/src/Illuminate/Routing/Router.php(1001): Illuminate\Routing\Router->dispatchToRoute(Object(Illuminate\Http\Request))
#16 /var/www/html/dev.example/vendor/laravel/framework/src/Illuminate/Foundation/Application.php(775): Illuminate\Routing\Router->dispatch(Object(Illuminate\Http\Request))
#17 /var/www/html/dev.example/vendor/laravel/framework/src/Illuminate/Foundation/Application.php(745): Illuminate\Foundation\Application->dispatch(Object(Illuminate\Http\Request))
#18 /var/www/html/dev.example/vendor/laravel/framework/src/Illuminate/Session/Middleware.php(72): Illuminate\Foundation\Application->handle(Object(Illuminate\Http\Request), 1, true)
#19 /var/www/html/dev.example/vendor/laravel/framework/src/Illuminate/Cookie/Queue.php(47): Illuminate\Session\Middleware->handle(Object(Illuminate\Http\Request), 1, true)
#20 /var/www/html/dev.example/vendor/laravel/framework/src/Illuminate/Cookie/Guard.php(51): Illuminate\Cookie\Queue->handle(Object(Illuminate\Http\Request), 1, true)
#21 /var/www/html/dev.example/vendor/stack/builder/src/Stack/StackedHttpKernel.php(23): Illuminate\Cookie\Guard->handle(Object(Illuminate\Http\Request), 1, true)
#22 /var/www/html/dev.example/vendor/laravel/framework/src/Illuminate/Foundation/Application.php(641): Stack\StackedHttpKernel->handle(Object(Illuminate\Http\Request))
#23 /var/www/html/dev.example/public/index.php(49): Illuminate\Foundation\Application->run()
#24 {main} [] []
在 Bigcommerce/Api/ClientError.php 中有一种方法 __toString()。评论出来。
我在 Laravel 4 应用程序中使用 Bigcommerce PHP SDK。 Bigcommerce SDK 配置为在发生错误时抛出异常。这些异常通常是 class Bigcommerce\Api\ClientError
。当抛出这些异常时,我并没有像通常对 Laravel 异常所做的那样在我的错误日志中看到详细的输出(包括堆栈跟踪、行号、文件位置等),我只在错误中看到一行日志,像这样:
[2015-05-05 21:19:00] production.ERROR: Client Error (404): The requested resource was not found. [] []
我需要在我的应用程序中做些什么来确保使用与其他 Laravel 异常相同的详细信息记录这些 Bigcommerce 异常吗?
这是我在 Laravel 中经常看到的错误输出示例。此输出是 Bigcommerce\Api\NetworkError
的结果。我不明白为什么我要查找的是此类异常的输出,但 Bigcommerce\Api\ClientError
不是:
[2015-05-05 13:22:22] production.ERROR: exception 'Bigcommerce\Api\NetworkError' with message 'Empty reply from server' in /var/www/html/dev.example/vendor/bigcommerce/api/src/Bigcommerce/Api/Connection.php:213
Stack trace:
#0 /var/www/html/dev.example/vendor/bigcommerce/api/src/Bigcommerce/Api/Connection.php(326): Bigcommerce\Api\Connection->handleResponse()
#1 /var/www/html/dev.example/vendor/bigcommerce/api/src/Bigcommerce/Api/Client.php(225): Bigcommerce\Api\Connection->post('https://api.big...', Object(stdClass))
#2 /var/www/html/dev.example/vendor/bigcommerce/api/src/Bigcommerce/Api/Client.php(436): Bigcommerce\Api\Client::createResource('/products', Array)
#3 /var/www/html/dev.example/app/spire_models/Product.php(873): Bigcommerce\Api\Client::createProduct(Array)
#4 /var/www/html/dev.example/app/spire_models/Product.php(35): Spire_models\Product->pushToExternal()
#5 /var/www/html/dev.example/app/extensions/SlaveTrait.php(26): Spire_models\Product->additionalSyncWithMaster()
#6 /var/www/html/dev.example/app/controllers/ProductInfoController.php(225): Spire_models\Product->syncWithMaster()
#7 [internal function]: ProductInfoController->saveProductDetails()
#8 /var/www/html/dev.example/vendor/laravel/framework/src/Illuminate/Routing/Controller.php(231): call_user_func_array(Array, Array)
#9 /var/www/html/dev.example/vendor/laravel/framework/src/Illuminate/Routing/ControllerDispatcher.php(93): Illuminate\Routing\Controller->callAction('saveProductDeta...', Array)
#10 /var/www/html/dev.example/vendor/laravel/framework/src/Illuminate/Routing/ControllerDispatcher.php(62): Illuminate\Routing\ControllerDispatcher->call(Object(ProductInfoController), Object(Illuminate\Routing\Route), 'saveProductDeta...')
#11 /var/www/html/dev.example/vendor/laravel/framework/src/Illuminate/Routing/Router.php(967): Illuminate\Routing\ControllerDispatcher->dispatch(Object(Illuminate\Routing\Route), Object(Illuminate\Http\Request), 'ProductInfoCont...', 'saveProductDeta...')
#12 [internal function]: Illuminate\Routing\Router->Illuminate\Routing\{closure}()
#13 /var/www/html/dev.example/vendor/laravel/framework/src/Illuminate/Routing/Route.php(109): call_user_func_array(Object(Closure), Array)
#14 /var/www/html/dev.example/vendor/laravel/framework/src/Illuminate/Routing/Router.php(1033): Illuminate\Routing\Route->run(Object(Illuminate\Http\Request))
#15 /var/www/html/dev.example/vendor/laravel/framework/src/Illuminate/Routing/Router.php(1001): Illuminate\Routing\Router->dispatchToRoute(Object(Illuminate\Http\Request))
#16 /var/www/html/dev.example/vendor/laravel/framework/src/Illuminate/Foundation/Application.php(775): Illuminate\Routing\Router->dispatch(Object(Illuminate\Http\Request))
#17 /var/www/html/dev.example/vendor/laravel/framework/src/Illuminate/Foundation/Application.php(745): Illuminate\Foundation\Application->dispatch(Object(Illuminate\Http\Request))
#18 /var/www/html/dev.example/vendor/laravel/framework/src/Illuminate/Session/Middleware.php(72): Illuminate\Foundation\Application->handle(Object(Illuminate\Http\Request), 1, true)
#19 /var/www/html/dev.example/vendor/laravel/framework/src/Illuminate/Cookie/Queue.php(47): Illuminate\Session\Middleware->handle(Object(Illuminate\Http\Request), 1, true)
#20 /var/www/html/dev.example/vendor/laravel/framework/src/Illuminate/Cookie/Guard.php(51): Illuminate\Cookie\Queue->handle(Object(Illuminate\Http\Request), 1, true)
#21 /var/www/html/dev.example/vendor/stack/builder/src/Stack/StackedHttpKernel.php(23): Illuminate\Cookie\Guard->handle(Object(Illuminate\Http\Request), 1, true)
#22 /var/www/html/dev.example/vendor/laravel/framework/src/Illuminate/Foundation/Application.php(641): Stack\StackedHttpKernel->handle(Object(Illuminate\Http\Request))
#23 /var/www/html/dev.example/public/index.php(49): Illuminate\Foundation\Application->run()
#24 {main} [] []
在 Bigcommerce/Api/ClientError.php 中有一种方法 __toString()。评论出来。