Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Parse errors not shown? #40

Closed
DaneEveritt opened this issue May 5, 2014 · 12 comments
Closed

Parse errors not shown? #40

DaneEveritt opened this issue May 5, 2014 · 12 comments

Comments

@DaneEveritt
Copy link

I can't seem to get Tracy to handle Syntax/Parse errors on my server, is there something I am missing?

I am using the code below, it catches Exceptions, but not Syntax errors for some reason.

use Tracy\Debugger;
Debugger::enable(Debugger::DEVELOPMENT, dirname(__DIR__).'/logs');
Debugger::$strictMode = TRUE;
@dg
Copy link
Member

dg commented May 5, 2014

Is syntax error in file, where is also Debugger::enable()?

@DaneEveritt
Copy link
Author

The syntax error is in a different file, but the debugger code is included on the pages.

@dg
Copy link
Member

dg commented May 5, 2014

The point is: are you sure that Debugger::enable() is called?

@DaneEveritt
Copy link
Author

Yeah, the code is here: https://github.com/DaneEveritt/PufferPanel/blob/master/src/framework/framework.core.php#L40

It works fine if an exception is thrown, but for syntax errors and stuff it doesn't do anything.

@JanTvrdik
Copy link
Contributor

@DaneEveritt The problem is that you include framework.core.php (which contains Debugger::enable()) from a file which contains a syntax error, therefore the file is never executed, therefore the include is never executed and finally therefore Debugger::enable() is not called.

@DaneEveritt
Copy link
Author

@JanTvrdik I tried to get tracy to work correctly with an error, this is the code from my test file:

<?php 

require_once('../vendor/autoload.php');

use Tracy\Debugger;
Debugger::enable(Debugger::DETECT);
Debugger::$strictMode = TRUE;


echo "hello"
echo "something else"
?>

This error was thrown:

[06-May-2014 12:04:37 America/New_York] PHP Parse error:  syntax error, unexpected 'echo' (T_ECHO), expecting ',' or ';' in test.php on line 11

However, tracy did not display any error page or do anything.

@dg
Copy link
Member

dg commented May 6, 2014

Again:

  • file contains a syntax error
  • therefore the file is never executed
  • therefore Debugger::enable() is not called

Tracy shows parse errors, but in your example Tracy was not enabled.

@DaneEveritt
Copy link
Author

Oh I understand now, sorry about that.

So if I include a file with a syntax error into a file that has tracy enabled it will work, just not the other way around.

@fprochazka
Copy link
Contributor

@DaneEveritt exactly.

@DaneEveritt
Copy link
Author

Time to figure out how to implement this in a way that can catch those in my code then. At least it works fine for exceptions which are the bigger problem, syntax errors don't usually make it past local development.

@dg
Copy link
Member

dg commented May 6, 2014

Try to run Tracy as soon as possible, in first script.

@DaneEveritt
Copy link
Author

The problem is that the way I am running it won't catch the syntax errors because I included it in the core file which is then included on all the pages. Based on the above responses I would need to be including all of the pages onto the core file for it to catch the errors, which isn't feasible.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants