xref: /plugin/davcal/vendor/sabre/xml/lib/LibXMLException.php (revision a1a3b6794e0e143a4a8b51d3185ce2d339be61ab)
1*a1a3b679SAndreas Boehler<?php
2*a1a3b679SAndreas Boehler
3*a1a3b679SAndreas Boehlernamespace Sabre\Xml;
4*a1a3b679SAndreas Boehler
5*a1a3b679SAndreas Boehleruse
6*a1a3b679SAndreas Boehler    LibXMLError;
7*a1a3b679SAndreas Boehler
8*a1a3b679SAndreas Boehler/**
9*a1a3b679SAndreas Boehler * This exception is thrown when the Readers runs into a parsing error.
10*a1a3b679SAndreas Boehler *
11*a1a3b679SAndreas Boehler * This exception effectively wraps 1 or more LibXMLError objects.
12*a1a3b679SAndreas Boehler *
13*a1a3b679SAndreas Boehler * @copyright Copyright (C) 2009-2015 fruux GmbH (https://fruux.com/).
14*a1a3b679SAndreas Boehler * @author Evert Pot (http://evertpot.com/)
15*a1a3b679SAndreas Boehler * @license http://sabre.io/license/ Modified BSD License
16*a1a3b679SAndreas Boehler */
17*a1a3b679SAndreas Boehlerclass LibXMLException extends ParseException {
18*a1a3b679SAndreas Boehler
19*a1a3b679SAndreas Boehler    /**
20*a1a3b679SAndreas Boehler     * The error list.
21*a1a3b679SAndreas Boehler     *
22*a1a3b679SAndreas Boehler     * @var LibXMLError[]
23*a1a3b679SAndreas Boehler     */
24*a1a3b679SAndreas Boehler    protected $errors;
25*a1a3b679SAndreas Boehler
26*a1a3b679SAndreas Boehler    /**
27*a1a3b679SAndreas Boehler     * Creates the exception.
28*a1a3b679SAndreas Boehler     *
29*a1a3b679SAndreas Boehler     * You should pass a list of LibXMLError objects in its constructor.
30*a1a3b679SAndreas Boehler     *
31*a1a3b679SAndreas Boehler     * @param LibXMLError[] $errors
32*a1a3b679SAndreas Boehler     * @param int $code
33*a1a3b679SAndreas Boehler     * @param Exception $previousException
34*a1a3b679SAndreas Boehler     */
35*a1a3b679SAndreas Boehler    function __construct(array $errors, $code = null, Exception $previousException = null) {
36*a1a3b679SAndreas Boehler
37*a1a3b679SAndreas Boehler        $this->errors = $errors;
38*a1a3b679SAndreas Boehler        parent::__construct($errors[0]->message . ' on line ' . $errors[0]->line . ', column ' . $errors[0]->column, $code, $previousException);
39*a1a3b679SAndreas Boehler
40*a1a3b679SAndreas Boehler    }
41*a1a3b679SAndreas Boehler
42*a1a3b679SAndreas Boehler    /**
43*a1a3b679SAndreas Boehler     * Returns the LibXML errors
44*a1a3b679SAndreas Boehler     *
45*a1a3b679SAndreas Boehler     * @return void
46*a1a3b679SAndreas Boehler     */
47*a1a3b679SAndreas Boehler    function getErrors() {
48*a1a3b679SAndreas Boehler
49*a1a3b679SAndreas Boehler        return $this->errors;
50*a1a3b679SAndreas Boehler
51*a1a3b679SAndreas Boehler    }
52*a1a3b679SAndreas Boehler
53*a1a3b679SAndreas Boehler}
54