Skip to content

Commit 45f7b3b

Browse files
committed
Use SourceException class instead of raw \Exception
1 parent 1c572eb commit 45f7b3b

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

lib/Sabberworm/CSS/Parser.php

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
use Sabberworm\CSS\CSSList\CSSList;
66
use Sabberworm\CSS\CSSList\Document;
77
use Sabberworm\CSS\CSSList\KeyFrame;
8+
use Sabberworm\CSS\Parsing\SourceException;
89
use Sabberworm\CSS\Property\AtRule;
910
use Sabberworm\CSS\Property\Import;
1011
use Sabberworm\CSS\Property\Charset;
@@ -100,7 +101,7 @@ private function parseList(CSSList $oList, $bIsRoot = false) {
100101
$this->consumeWhiteSpace();
101102
}
102103
if (!$bIsRoot) {
103-
throw new \Exception("Unexpected end of document");
104+
throw new SourceException("Unexpected end of document", $this->iLineNo);
104105
}
105106
}
106107

@@ -120,7 +121,7 @@ private function parseListItem(CSSList $oList, $bIsRoot = false) {
120121
} else if ($this->comes('}')) {
121122
$this->consume('}');
122123
if ($bIsRoot) {
123-
throw new \Exception("Unopened {");
124+
throw new SourceException("Unopened {", $this->iLineNo);
124125
} else {
125126
return null;
126127
}
@@ -235,7 +236,7 @@ private function parseStringValue() {
235236
while (!$this->comes($sQuote)) {
236237
$sContent = $this->parseCharacter(false);
237238
if ($sContent === null) {
238-
throw new \Exception("Non-well-formed quoted string {$this->peek(3)}");
239+
throw new \Exception("Non-well-formed quoted string {$this->peek(3)}", $this->iLineNo);
239240
}
240241
$sResult .= $sContent;
241242
}

0 commit comments

Comments
 (0)