PluginProbe
Automatic YouTube Gallery – Embed Auto-Updating YouTube Video Galleries, Feeds, Playlists & Channels / 1.2.0
Automatic YouTube Gallery – Embed Auto-Updating YouTube Video Galleries, Feeds, Playlists & Channels v1.2.0
2.9.1 2.9.0 trunk 1.0.0 1.1.0 1.2.0 1.3.0 1.4.0 1.5.0 1.6.0 1.6.1 1.6.2 1.6.3 1.6.4 1.6.5 2.0.0 2.1.0 2.2.0 2.3.2 2.3.3 2.3.5 2.3.6 2.3.8 2.3.9 2.4.3 All 37 releases
automatic-youtube-gallery / freemius / includes / sdk / Exceptions / Exception.php

Exception.php in Automatic YouTube Gallery – Embed Auto-Updating YouTube Video Galleries, Feeds, Playlists & Channels 1.2.0, at freemius/includes/sdk/Exceptions/Exception.php

74 lines 1.7 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 if ( ! class_exists( 'Freemius_Exception' ) ) {
3 /**
4 * Thrown when an API call returns an exception.
5 *
6 */
7 class Freemius_Exception extends Exception {
8 protected $_result;
9 protected $_type;
10 protected $_code;
11
12 /**
13 * Make a new API Exception with the given result.
14 *
15 * @param array $result The result from the API server.
16 */
17 public function __construct( $result ) {
18 $this->_result = $result;
19
20 $code = 0;
21 $message = 'Unknown error, please check GetResult().';
22 $type = '';
23
24 if ( isset( $result['error'] ) && is_array( $result['error'] ) ) {
25 if ( isset( $result['error']['code'] ) ) {
26 $code = $result['error']['code'];
27 }
28 if ( isset( $result['error']['message'] ) ) {
29 $message = $result['error']['message'];
30 }
31 if ( isset( $result['error']['type'] ) ) {
32 $type = $result['error']['type'];
33 }
34 }
35
36 $this->_type = $type;
37 $this->_code = $code;
38
39 parent::__construct( $message, is_numeric( $code ) ? $code : 0 );
40 }
41
42 /**
43 * Return the associated result object returned by the API server.
44 *
45 * @return array The result from the API server
46 */
47 public function getResult() {
48 return $this->_result;
49 }
50
51 public function getStringCode() {
52 return $this->_code;
53 }
54
55 public function getType() {
56 return $this->_type;
57 }
58
59 /**
60 * To make debugging easier.
61 *
62 * @return string The string representation of the error
63 */
64 public function __toString() {
65 $str = $this->getType() . ': ';
66
67 if ( $this->code != 0 ) {
68 $str .= $this->getStringCode() . ': ';
69 }
70
71 return $str . $this->getMessage();
72 }
73 }
74 }