GraphException.php
51 lines
| 1 | <?php |
| 2 | /** |
| 3 | * Copyright (c) Microsoft Corporation. All Rights Reserved. |
| 4 | * Licensed under the MIT License. See License in the project root |
| 5 | * for license information. |
| 6 | * |
| 7 | * Exceptions File |
| 8 | * PHP version 7 |
| 9 | * |
| 10 | * @category Library |
| 11 | * @package Microsoft.Graph |
| 12 | * @copyright 2016 Microsoft Corporation |
| 13 | * @license https://opensource.org/licenses/MIT MIT License |
| 14 | * @version GIT: 0.1.0 |
| 15 | * @link https://graph.microsoft.io/ |
| 16 | */ |
| 17 | |
| 18 | namespace Microsoft\Graph\Exception; |
| 19 | |
| 20 | /** |
| 21 | * Class GraphException |
| 22 | * |
| 23 | * @category Library |
| 24 | * @package Microsoft.Graph |
| 25 | * @license https://opensource.org/licenses/MIT MIT License |
| 26 | * @link https://graph.microsoft.io/ |
| 27 | */ |
| 28 | class GraphException extends \Exception |
| 29 | { |
| 30 | /** |
| 31 | * Construct a new Graph Exception handler |
| 32 | * |
| 33 | * @param string $message The error to send |
| 34 | * @param int $code The error code associated with the error |
| 35 | * @param \Exception $previous The last error sent, defaults to null |
| 36 | */ |
| 37 | public function __construct($message, $code = 0, $previous = null) |
| 38 | { |
| 39 | parent::__construct($message, $code, $previous); |
| 40 | } |
| 41 | |
| 42 | /** |
| 43 | * Stringify the returned error and message |
| 44 | * |
| 45 | * @return string The returned string message |
| 46 | */ |
| 47 | public function __toString() |
| 48 | { |
| 49 | return __CLASS__ . ": [{$this->code}]: {$this->message}\n"; |
| 50 | } |
| 51 | } |