Skip to content

Commit

Permalink
specialize the pre processor error type #11
Browse files Browse the repository at this point in the history
  • Loading branch information
marcioAlmada committed Nov 28, 2015
1 parent c8837e1 commit 12df3c1
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/Halt.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@

namespace Yay;

class Halt extends YayException {}
class Halt extends YayParseError {}
2 changes: 1 addition & 1 deletion src/Macro.php
Original file line number Diff line number Diff line change
Expand Up @@ -586,6 +586,6 @@ private function lookupTokenType(Token $token) : int {
}

private function fail(string $error, ...$args) {
throw new YayException(sprintf($error, ...$args));
throw new YayParseError(sprintf($error, ...$args));
}
}
5 changes: 5 additions & 0 deletions src/YayParseError.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<?php declare(strict_types=1);

namespace Yay;

class YayParseError extends \ParseError {}
4 changes: 3 additions & 1 deletion tests/SpecsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -101,9 +101,11 @@ function run() {

try {
$this->out = yay_parse($this->source, '');
} catch(\Exception $e) {
} catch(YayParseError $e) {
$this->out = $e->getMessage();
// $this->out = (string) $e;
} catch(\Exception $e) {
$this->out = $e->getMessage();
}

try{
Expand Down

0 comments on commit 12df3c1

Please sign in to comment.