ConfigurationException.php 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. <?php
  2. /*
  3. * $Id: ConfigurationException.php 905 2010-10-05 16:28:03Z mrook $
  4. *
  5. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  6. * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  7. * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
  8. * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
  9. * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  10. * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  11. * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
  12. * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  13. * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  14. * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
  15. * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  16. *
  17. * This software consists of voluntary contributions made by many individuals
  18. * and is licensed under the LGPL. For more information please see
  19. * <http://phing.info>.
  20. */
  21. /**
  22. * ConfigurationException is thrown by Phing during the configuration and setup phase of the project.
  23. *
  24. * @author Hans Lellelid <hans@xmpl.org>
  25. * @version $Revision: 905 $
  26. * @package phing
  27. */
  28. class ConfigurationException extends Exception {
  29. /**
  30. * Location in the xml file.
  31. * @var Location
  32. */
  33. protected $location;
  34. /**
  35. * The nested "cause" exception.
  36. * @var Exception
  37. */
  38. protected $cause;
  39. /**
  40. * Construct a BuildException.
  41. * Supported signatures:
  42. * throw new BuildException($causeExc);
  43. * throw new BuildException($msg);
  44. * throw new BuildException($msg, $causeExc);
  45. */
  46. function __construct($p1, $p2 = null, $p3 = null) {
  47. $cause = null;
  48. $msg = "";
  49. if ($p2 !== null) {
  50. if ($p2 instanceof Exception) {
  51. $cause = $p2;
  52. $msg = $p1;
  53. }
  54. } elseif ($p1 instanceof Exception) {
  55. $cause = $p1;
  56. } else {
  57. $msg = $p1;
  58. }
  59. parent::__construct($msg);
  60. if ($cause !== null) {
  61. $this->cause = $cause;
  62. $this->message .= " [wrapped: " . $cause->getMessage() ."]";
  63. }
  64. }
  65. /**
  66. * Gets the cause exception.
  67. *
  68. * @return Exception
  69. */
  70. public function getCause() {
  71. return $this->cause;
  72. }
  73. }