MindscapeHQ/raygun4php

Does Not Report Actual Error Line Number & File

Closed this issue · 5 comments

I was testing Raygun out for PHP, but I noticed that it doesn't actually report the file name and line number of the actual error, which is the most important part.

I am just manually doing a $raygunClient->SendException($exception) and I get a something like this:

screen shot 2015-09-05 at 12 05 10 pm

The error was on ProductController.php:39, something I know cuz 1) I put the error there and 2) if I log $exception->getFile() and $exception->getLine() (or it's even reported in $exception->getTraceAsString()), I can find this information.

Am I doing something wrong, or would it be possible for this information to be added to the error reports?

Here's the relevant part of the raw data (which does have the file, but it isn't displayed in any of the "pretty views" but no line number):

{
     "Error": {
          "Message": "Symfony\\Component\\Debug\\Exception\\FatalErrorException: Call to undefined function GoDirectFoods\\Http\\Controllers\\foo()",
          "ClassName": "Symfony\\Component\\Debug\\Exception\\FatalErrorException",
          "StackTrace": [
               {
                    "LineNumber": 131,
                    "ClassName": "Symfony\\Component\\Debug\\Exception\\FatalErrorException",
                    "FileName": "/home/godirectfoods/vendor/laravel/framework/src/Illuminate/Foundation/Bootstrap/HandleExceptions.php",
                    "MethodName": "__construct"
               },
               {
                    "LineNumber": 116,
                    "ClassName": "Illuminate\\Foundation\\Bootstrap\\HandleExceptions",
                    "FileName": "/home/godirectfoods/vendor/laravel/framework/src/Illuminate/Foundation/Bootstrap/HandleExceptions.php",
                    "MethodName": "fatalExceptionFromError"
               },
               {
                    "LineNumber": 0,
                    "ClassName": "Illuminate\\Foundation\\Bootstrap\\HandleExceptions",
                    "FileName": "/home/godirectfoods/vendor/laravel/framework/src/Illuminate/Foundation/Bootstrap/HandleExceptions.php",
                    "MethodName": "handleShutdown"
               },
               {
                    "LineNumber": 246,
                    "ClassName": "GoDirectFoods\\Http\\Controllers\\ProductController",
                    "FileName": "/home/godirectfoods/vendor/laravel/framework/src/Illuminate/Routing/Controller.php",
                    "MethodName": "index"
               },
               {
                    "LineNumber": 246,
                    "ClassName": "",
                    "FileName": "/home/godirectfoods/vendor/laravel/framework/src/Illuminate/Routing/Controller.php",
                    "MethodName": "call_user_func_array:{/home/godirectfoods/vendor/laravel/framework/src/Illuminate/Routing/Controller.php:246}"
               },
               {
                    "LineNumber": 162,
                    "ClassName": "Illuminate\\Routing\\Controller",
                    "FileName": "/home/godirectfoods/vendor/laravel/framework/src/Illuminate/Routing/ControllerDispatcher.php",
                    "MethodName": "callAction"
               },
               {
                    "LineNumber": 107,
                    "ClassName": "Illuminate\\Routing\\ControllerDispatcher",
                    "FileName": "/home/godirectfoods/vendor/laravel/framework/src/Illuminate/Routing/ControllerDispatcher.php",
                    "MethodName": "call"
               },
               {
                    "LineNumber": 141,
                    "ClassName": "Illuminate\\Routing\\ControllerDispatcher",
                    "FileName": "/home/godirectfoods/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php",
                    "MethodName": "Illuminate\\Routing\\{closure}"
               },
               {
                    "LineNumber": 141,
                    "ClassName": "",
                    "FileName": "/home/godirectfoods/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php",
                    "MethodName": "call_user_func:{/home/godirectfoods/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php:141}"
               },
               {
                    "LineNumber": 101,
                    "ClassName": "Illuminate\\Pipeline\\Pipeline",
                    "FileName": "/home/godirectfoods/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php",
                    "MethodName": "Illuminate\\Pipeline\\{closure}"
               },
               {
                    "LineNumber": 101,
                    "ClassName": "",
                    "FileName": "/home/godirectfoods/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php",
                    "MethodName": "call_user_func:{/home/godirectfoods/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php:101}"
               },
               {
                    "LineNumber": 108,
                    "ClassName": "Illuminate\\Pipeline\\Pipeline",
                    "FileName": "/home/godirectfoods/vendor/laravel/framework/src/Illuminate/Routing/ControllerDispatcher.php",
                    "MethodName": "then"
               },
               {
                    "LineNumber": 67,
                    "ClassName": "Illuminate\\Routing\\ControllerDispatcher",
                    "FileName": "/home/godirectfoods/vendor/laravel/framework/src/Illuminate/Routing/ControllerDispatcher.php",
                    "MethodName": "callWithinStack"
               },
               {
                    "LineNumber": 204,
                    "ClassName": "Illuminate\\Routing\\ControllerDispatcher",
                    "FileName": "/home/godirectfoods/vendor/laravel/framework/src/Illuminate/Routing/Route.php",
                    "MethodName": "dispatch"
               },
               {
                    "LineNumber": 134,
                    "ClassName": "Illuminate\\Routing\\Route",
                    "FileName": "/home/godirectfoods/vendor/laravel/framework/src/Illuminate/Routing/Route.php",
                    "MethodName": "runWithCustomDispatcher"
               },
               {
                    "LineNumber": 701,
                    "ClassName": "Illuminate\\Routing\\Route",
                    "FileName": "/home/godirectfoods/vendor/laravel/framework/src/Illuminate/Routing/Router.php",
                    "MethodName": "run"
               },
               {
                    "LineNumber": 141,
                    "ClassName": "Illuminate\\Routing\\Router",
                    "FileName": "/home/godirectfoods/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php",
                    "MethodName": "Illuminate\\Routing\\{closure}"
               },
               {
                    "LineNumber": 141,
                    "ClassName": "",
                    "FileName": "/home/godirectfoods/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php",
                    "MethodName": "call_user_func:{/home/godirectfoods/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php:141}"
               },
               {
                    "LineNumber": 32,
                    "ClassName": "Illuminate\\Pipeline\\Pipeline",
                    "FileName": "/home/godirectfoods/app/Http/Middleware/DatabaseTransactions.php",
                    "MethodName": "Illuminate\\Pipeline\\{closure}"
               },
               {
                    "LineNumber": 451,
                    "ClassName": "GoDirectFoods\\Http\\Middleware\\DatabaseTransactions",
                    "FileName": "/home/godirectfoods/vendor/laravel/framework/src/Illuminate/Database/Connection.php",
                    "MethodName": "GoDirectFoods\\Http\\Middleware\\{closure}"
               },
               {
                    "LineNumber": 33,
                    "ClassName": "Illuminate\\Database\\Connection",
                    "FileName": "/home/godirectfoods/app/Http/Middleware/DatabaseTransactions.php",
                    "MethodName": "transaction"
               },
               {
                    "LineNumber": 125,
                    "ClassName": "GoDirectFoods\\Http\\Middleware\\DatabaseTransactions",
                    "FileName": "/home/godirectfoods/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php",
                    "MethodName": "handle"
               },
               {
                    "LineNumber": 101,
                    "ClassName": "Illuminate\\Pipeline\\Pipeline",
                    "FileName": "/home/godirectfoods/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php",
                    "MethodName": "Illuminate\\Pipeline\\{closure}"
               },
               {
                    "LineNumber": 101,
                    "ClassName": "",
                    "FileName": "/home/godirectfoods/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php",
                    "MethodName": "call_user_func:{/home/godirectfoods/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php:101}"
               },
               {
                    "LineNumber": 703,
                    "ClassName": "Illuminate\\Pipeline\\Pipeline",
                    "FileName": "/home/godirectfoods/vendor/laravel/framework/src/Illuminate/Routing/Router.php",
                    "MethodName": "then"
               },
               {
                    "LineNumber": 670,
                    "ClassName": "Illuminate\\Routing\\Router",
                    "FileName": "/home/godirectfoods/vendor/laravel/framework/src/Illuminate/Routing/Router.php",
                    "MethodName": "runRouteWithinStack"
               },
               {
                    "LineNumber": 628,
                    "ClassName": "Illuminate\\Routing\\Router",
                    "FileName": "/home/godirectfoods/vendor/laravel/framework/src/Illuminate/Routing/Router.php",
                    "MethodName": "dispatchToRoute"
               },
               {
                    "LineNumber": 214,
                    "ClassName": "Illuminate\\Routing\\Router",
                    "FileName": "/home/godirectfoods/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php",
                    "MethodName": "dispatch"
               },
               {
                    "LineNumber": 141,
                    "ClassName": "Illuminate\\Foundation\\Http\\Kernel",
                    "FileName": "/home/godirectfoods/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php",
                    "MethodName": "Illuminate\\Foundation\\Http\\{closure}"
               },
               {
                    "LineNumber": 141,
                    "ClassName": "",
                    "FileName": "/home/godirectfoods/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php",
                    "MethodName": "call_user_func:{/home/godirectfoods/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php:141}"
               },
               {
                    "LineNumber": 48,
                    "ClassName": "Illuminate\\Pipeline\\Pipeline",
                    "FileName": "/home/godirectfoods/app/Http/Middleware/Timezone.php",
                    "MethodName": "Illuminate\\Pipeline\\{closure}"
               },
               {
                    "LineNumber": 125,
                    "ClassName": "GoDirectFoods\\Http\\Middleware\\Timezone",
                    "FileName": "/home/godirectfoods/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php",
                    "MethodName": "handle"
               },
               {
                    "LineNumber": 43,
                    "ClassName": "Illuminate\\Pipeline\\Pipeline",
                    "FileName": "/home/godirectfoods/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/VerifyCsrfToken.php",
                    "MethodName": "Illuminate\\Pipeline\\{closure}"
               },
               {
                    "LineNumber": 125,
                    "ClassName": "Illuminate\\Foundation\\Http\\Middleware\\VerifyCsrfToken",
                    "FileName": "/home/godirectfoods/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php",
                    "MethodName": "handle"
               },
               {
                    "LineNumber": 55,
                    "ClassName": "Illuminate\\Pipeline\\Pipeline",
                    "FileName": "/home/godirectfoods/vendor/laravel/framework/src/Illuminate/View/Middleware/ShareErrorsFromSession.php",
                    "MethodName": "Illuminate\\Pipeline\\{closure}"
               },
               {
                    "LineNumber": 125,
                    "ClassName": "Illuminate\\View\\Middleware\\ShareErrorsFromSession",
                    "FileName": "/home/godirectfoods/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php",
                    "MethodName": "handle"
               },
               {
                    "LineNumber": 61,
                    "ClassName": "Illuminate\\Pipeline\\Pipeline",
                    "FileName": "/home/godirectfoods/vendor/laravel/framework/src/Illuminate/Session/Middleware/StartSession.php",
                    "MethodName": "Illuminate\\Pipeline\\{closure}"
               },
               {
                    "LineNumber": 125,
                    "ClassName": "Illuminate\\Session\\Middleware\\StartSession",
                    "FileName": "/home/godirectfoods/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php",
                    "MethodName": "handle"
               },
               {
                    "LineNumber": 36,
                    "ClassName": "Illuminate\\Pipeline\\Pipeline",
                    "FileName": "/home/godirectfoods/vendor/laravel/framework/src/Illuminate/Cookie/Middleware/AddQueuedCookiesToResponse.php",
                    "MethodName": "Illuminate\\Pipeline\\{closure}"
               },
               {
                    "LineNumber": 125,
                    "ClassName": "Illuminate\\Cookie\\Middleware\\AddQueuedCookiesToResponse",
                    "FileName": "/home/godirectfoods/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php",
                    "MethodName": "handle"
               },
               {
                    "LineNumber": 40,
                    "ClassName": "Illuminate\\Pipeline\\Pipeline",
                    "FileName": "/home/godirectfoods/vendor/laravel/framework/src/Illuminate/Cookie/Middleware/EncryptCookies.php",
                    "MethodName": "Illuminate\\Pipeline\\{closure}"
               },
               {
                    "LineNumber": 125,
                    "ClassName": "Illuminate\\Cookie\\Middleware\\EncryptCookies",
                    "FileName": "/home/godirectfoods/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php",
                    "MethodName": "handle"
               },
               {
                    "LineNumber": 42,
                    "ClassName": "Illuminate\\Pipeline\\Pipeline",
                    "FileName": "/home/godirectfoods/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/CheckForMaintenanceMode.php",
                    "MethodName": "Illuminate\\Pipeline\\{closure}"
               },
               {
                    "LineNumber": 125,
                    "ClassName": "Illuminate\\Foundation\\Http\\Middleware\\CheckForMaintenanceMode",
                    "FileName": "/home/godirectfoods/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php",
                    "MethodName": "handle"
               },
               {
                    "LineNumber": 101,
                    "ClassName": "Illuminate\\Pipeline\\Pipeline",
                    "FileName": "/home/godirectfoods/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php",
                    "MethodName": "Illuminate\\Pipeline\\{closure}"
               },
               {
                    "LineNumber": 101,
                    "ClassName": "",
                    "FileName": "/home/godirectfoods/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php",
                    "MethodName": "call_user_func:{/home/godirectfoods/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php:101}"
               },
               {
                    "LineNumber": 115,
                    "ClassName": "Illuminate\\Pipeline\\Pipeline",
                    "FileName": "/home/godirectfoods/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php",
                    "MethodName": "then"
               },
               {
                    "LineNumber": 84,
                    "ClassName": "Illuminate\\Foundation\\Http\\Kernel",
                    "FileName": "/home/godirectfoods/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php",
                    "MethodName": "sendRequestThroughRouter"
               },
               {
                    "LineNumber": 54,
                    "ClassName": "Illuminate\\Foundation\\Http\\Kernel",
                    "FileName": "/home/godirectfoods/public/index.php",
                    "MethodName": "handle"
               },
               {
                    "LineNumber": 0,
                    "ClassName": "",
                    "FileName": "/home/godirectfoods/public/index.php",
                    "MethodName": "{main}"
               }
          ],
          "FileName": "ProductController.php",
          "Data": null
     }
}

Just to clarify, what is the file/line/class/method which the FatalErrorException is occurring on? You mention that it is included in the raw view but not in the prettyprinted view. Assuming the actual SendException call is occuring in ProductController? Also, is this object a subclass of ErrorException or Exception?

After inspecting this it looks like Laravel may be altering this process somehow. Are you sending it from an override of report() as at http://laravel.com/docs/5.1/errors#the-exception-handler?

In ProductController.php, I just had foo();, which I knew would error. The error was in ProductController.php:39. The raw view actually only had the file, and did not have the line anywhere. ProductController was not found anywhere on the pretty print page.

It's a subclass of Exception. Even if it is some special Exception subclass, it should (and does) still have the methods to get line and file.

I'm sending it as an override of handle, not report in the Exception Handler (tho report is probably more appropriate!). Either way, they both have type-checked \Exceptions passed in.

I am using Laravel 5.2 and am sending the exception in my override of report as referenced by @fundead but in Raygun I am not getting a stack trace or a line number. In this example the syntax error is actually in ContactController.php.

"Error": { "Message": "Symfony\\Component\\Debug\\Exception\\FatalErrorException: syntax error, unexpected 'if' (T_IF)", "ClassName": "Symfony\\Component\\Debug\\Exception\\FatalErrorException", "StackTrace": [], "FileName": "ContactController.php", "Data": null }

Thanks for providing this, that should be enough of a repro for us to locate the cause of the issue. This provider isn't immediately scheduled for a review due to other pressing work in the pipeline but I have added this to the queue and will look at resolving this for you when next possible.

Closing this issue for now. If you wish to see this issue addressed please create a new issue or post within our forums (https://raygun.com/forums). Thank you.