1<?php
2/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
3
4/**
5 * DNS Library for handling lookups and updates.
6 *
7 * PHP Version 5
8 *
9 * Copyright (c) 2010, Mike Pultz <mike@mikepultz.com>.
10 * All rights reserved.
11 *
12 * Redistribution and use in source and binary forms, with or without
13 * modification, are permitted provided that the following conditions
14 * are met:
15 *
16 *   * Redistributions of source code must retain the above copyright
17 *     notice, this list of conditions and the following disclaimer.
18 *
19 *   * Redistributions in binary form must reproduce the above copyright
20 *     notice, this list of conditions and the following disclaimer in
21 *     the documentation and/or other materials provided with the
22 *     distribution.
23 *
24 *   * Neither the name of Mike Pultz nor the names of his contributors
25 *     may be used to endorse or promote products derived from this
26 *     software without specific prior written permission.
27 *
28 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
29 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
30 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
31 * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
32 * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
33 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
34 * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
35 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
36 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRIC
37 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
38 * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
39 * POSSIBILITY OF SUCH DAMAGE.
40 *
41 * @category  Networking
42 * @package   Net_DNS2
43 * @author    Mike Pultz <mike@mikepultz.com>
44 * @copyright 2010 Mike Pultz <mike@mikepultz.com>
45 * @license   http://www.opensource.org/licenses/bsd-license.php  BSD License
46 * @version   SVN: $Id$
47 * @link      http://pear.php.net/package/Net_DNS2
48 * @since     File available since Release 0.6.0
49 */
50
51/**
52 * Exception handler used by Net_DNS2
53 *
54 * @category Networking
55 * @package  Net_DNS2
56 * @author   Mike Pultz <mike@mikepultz.com>
57 * @license  http://www.opensource.org/licenses/bsd-license.php  BSD License
58 * @link     http://pear.php.net/package/Net_DNS2
59 *
60 */
61class Net_DNS2_Exception extends Exception
62{
63    private $_request;
64    private $_response;
65
66    /**
67     * Constructor - overload the constructor so we can pass in the request
68     *               and response object (when it's available)
69     *
70     * @param string $message  the exception message
71     * @param int    $code     the exception code
72     * @param object $previous the previous Exception object
73     * @param object $request  the Net_DNS2_Packet_Request object for this request
74     * @param object $response the Net_DNS2_Packet_Response object for this request
75     *
76     * @access public
77     *
78     */
79    public function __construct(
80        $message = '',
81        $code = 0,
82        $previous = null,
83        Net_DNS2_Packet_Request $request = null,
84        Net_DNS2_Packet_Response $response = null
85    ) {
86        //
87        // store the request/response objects (if passed)
88        //
89        $this->_request = $request;
90        $this->_response = $response;
91
92        //
93        // call the parent constructor
94        //
95        // the "previous" argument was added in PHP 5.3.0
96        //
97        //      https://code.google.com/p/netdns2/issues/detail?id=25
98        //
99        if (version_compare(PHP_VERSION, '5.3.0', '>=') == true) {
100
101            parent::__construct($message, $code, $previous);
102        } else {
103
104            parent::__construct($message, $code);
105        }
106    }
107
108    /**
109     * returns the Net_DNS2_Packet_Request object (if available)
110     *
111     * @return Net_DNS2_Packet_Request object
112     * @access public
113     * @since  function available since release 1.3.1
114     *
115     */
116    public function getRequest()
117    {
118        return $this->_request;
119    }
120
121    /**
122     * returns the Net_DNS2_Packet_Response object (if available)
123     *
124     * @return Net_DNS2_Packet_Response object
125     * @access public
126     * @since  function available since release 1.3.1
127     *
128     */
129    public function getResponse()
130    {
131        return $this->_response;
132    }
133}
134
135/*
136 * Local variables:
137 * tab-width: 4
138 * c-basic-offset: 4
139 * c-hanging-comment-ender-p: nil
140 * End:
141 */
142?>
143