We have moved our forum to GitHub Discussions. For questions about Phalcon v3/v4/v5 you can visit here and for Phalcon v6 here.

Error Reporting

Hi All,

I am getting an error like this "The method "getDbRef" doesn't exist on model "Session"" I know what it means and why I am getting it. I am just sure I must be missing some debug flag as I would expect this error message to include the stack trace or at lest the file name and line number.

I have followed this post https://docs.phalcon.io/en/latest/reference/debug.html and enabled \Phalcon\Debug, it works well for exceptions thanks. Although this does not make any difference for errors like the above ( guessing no exception is thrown).

Is there more I need to do or is this the most info I can get?

Thank you.



98.9k

Exceptions like this:

The method "getDbRef" doesn't exist on model "Session"" 

They're thrown here: https://github.com/phalcon/cphalcon/blob/2.0.0/phalcon/mvc/model.zep#L3991

Fatal errors, warnings, notices and other messages are not exceptions themselves so it cannot be caught by Phalcon\Debug or try/catch block.

Is it likely or even possible in future releases it will include more info in the message e.g. file name and line number?



98.9k

In the case of exceptions, you have to print it: $e->getFile(), $e->getLine()

edited Oct '14

Yes I realize this but as you where saying this is not an exception. I was more meaning for this type of message that gets generated from the framework.



98.9k
Accepted
answer

It's an exception:

The method "getDbRef" doesn't exist on model "Session""

it's thrown here: https://github.com/phalcon/cphalcon/blob/2.0.0/phalcon/mvc/model.zep#L3991

Yep my bad sorry for wasting your time. Took me a bit but got what you where saying I did not notice I was actually catching the exception in the index.php and just printing out the message.

Thanks for the great framework!