1: <?php
2: // Parco
3: // Copyright (c) 2015 Niels Sonnich Poulsen (http://nielssp.dk)
4: // Licensed under the MIT license.
5: // See the LICENSE file or http://opensource.org/licenses/MIT for more information.
6: namespace Parco;
7:
8: /**
9: * A parse exception with positional information.
10: */
11: class ParseException extends \RuntimeException implements Positional
12: {
13: use Position;
14:
15: /**
16: * Construct parse exception from a parse result.
17: *
18: * @param Result $result Parse result.
19: * @param \Exception|null $previous Previous exception if any.
20: */
21: public function __construct(Result $result, \Exception $previous = null)
22: {
23: parent::__construct($result->message, 0, $previous);
24: $this->setPosition($result->getPosition());
25: }
26: }
27: