Skip to content

NeonAdapter: throw more meaningful error which contains the filename#136

Merged
ondrejmirtes merged 4 commits intophpstan:masterfrom
clxmstaab:better-exception
Feb 8, 2020
Merged

NeonAdapter: throw more meaningful error which contains the filename#136
ondrejmirtes merged 4 commits intophpstan:masterfrom
clxmstaab:better-exception

Conversation

@clxmstaab
Copy link
Copy Markdown
Contributor

before this change a error looks like

$ ../phpstan-src/bin/phpstan analyse -c phpstan.neon.dist --error-format baselineNeon  -vvv

In Decoder.php line 370:

  [Nette\Neon\Exception]
  Unexpected 'NULL' on line 2, column 1.

after this change we get a error message which also contains the actual path to the neon-file which contains the error.. its not always the one which gets passed by cli arg :)

$ ../phpstan-src/bin/phpstan analyse -c phpstan.neon.dist --error-format baselineNeon  -vvv

In NeonAdapter.php line 35:

  [Nette\Neon\Exception]
  Error while loading C:\dvl\Zend\DefaultWorkspace13\php-clxmobilenet/phpstan-baseline.neon: Unexpected 'NULL' on line 2, column 1.

try {
return $this->process((array) Neon::decode($contents), '', $file);
} catch (\Nette\Neon\Exception $e) {
throw new \Nette\Neon\Exception(sprintf('Error while loading %s: %s', $file, $e->getMessage()));
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We could add $e as the previousException.. not sure we need this though

@ondrejmirtes ondrejmirtes merged commit d5348d7 into phpstan:master Feb 8, 2020
@ondrejmirtes
Copy link
Copy Markdown
Member

Thank you!

@clxmstaab clxmstaab deleted the better-exception branch February 10, 2020 08:32
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

Successfully merging this pull request may close these issues.

3 participants