-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathCSException.php
More file actions
executable file
·86 lines (81 loc) · 2.32 KB
/
CSException.php
File metadata and controls
executable file
·86 lines (81 loc) · 2.32 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
<?php
/**
* CSException
* CSException Class is used to wrap the REST API error
*
* PHP version 5
*
* @category PHP
* @package Contentstack
* @author Uttam K Ukkoji <uttamukkoji@gmail.com>
* @author Rohit Mishra <rhtmishra4545@gmail.com>
* @copyright 2012-2021 Contentstack. All Rights Reserved
* @license https://github.com/contentstack/contentstack-php/blob/master/LICENSE.txt MIT Licence
* @link https://pear.php.net/package/contentstack
* */
namespace Contentstack\Error;
/**
* CSException
* CSException Class is used to wrap the REST API error
*
* @category PHP
* @package Contentstack
* @author Uttam K Ukkoji <uttamukkoji@gmail.com>
* @author Rohit Mishra <rhtmishra4545@gmail.com>
* @copyright 2012-2021 Contentstack. All Rights Reserved
* @license https://github.com/contentstack/contentstack-php/blob/master/LICENSE.txt MIT Licence
* @link https://pear.php.net/package/contentstack
* */
#[\AllowDynamicProperties]
class CSException extends \Exception
{
var $error_message;
var $error_code;
var $http_code;
/**
* CSException Class to initalize your ContentType
*
* @param string $error - Error message
* @param Stack $http_code - Erro code
* */
function __construct($error, $http_code = 412)
{
$error = json_decode($error, true);
$this->error_message = (
isset(
$error['error_message']
)
) ?
$error['error_message'] :
"It seems Contentstack is behaving badly.
Please contact support@contentstack.io.";
$this->error_code = (
isset($error['error_code'])
) ?
$error['error_code'] : null;
$this->errors = (
isset($error['errors'])
) ? $error['errors'] :
array();
$this->http_code = $http_code;
parent::__construct($this->error_message, $this->error_code, null);
}
/**
* To get http status_code of the current exception
*
* @return HttpCode|string
* */
function getStatusCode()
{
return $this->http_code;
}
/**
* Returns error details of current exception
*
* @return error|array
* */
function getErrors()
{
return $this->errors;
}
}