-
Notifications
You must be signed in to change notification settings - Fork 15
/
Copy pathMeetupExceptions.class.php
74 lines (60 loc) · 2.46 KB
/
MeetupExceptions.class.php
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
<?php
/**
* Contains all of the exceptions for the Meetup API Client
*/
/**
* Used when invalid parameters are passed to the API
*/
class MeetupInvalidParametersException extends Exception {
// Redefine the exception so message isn't optional
public function __construct( $RequiredParameters ) {
// some code
$message = "<p><b>A required parameter was not found.</b> Please view the list of parameters: " . implode(", ", $RequiredParameters) . "</p>";
// make sure everything is assigned properly
parent::__construct( $message, E_USER_ERROR, null );
}
// custom string representation of object
public function __toString() {
return __CLASS__ . ": {$this->message}\n";
}
}
// 400 Bad request when there was a problem with the request
class MeetupBadRequestException extends Exception {
// Redefine the exception so message isn't optional
public function __construct($Url, $Response) {
// some code
$message = "<p><b>400 HTTP Error:</b> Error bad request to $Url<br/>Details: {$Response['details']}<br/>Problem: {$Response['problem']}</p>";
// make sure everything is assigned properly
parent::__construct($message, E_USER_ERROR, null);
}
// custom string representation of object
public function __toString() {
return __CLASS__ . ": {$this->message}\n";
}
}
class MeetupUnauthorizedRequestException extends Exception {
// Redefine the exception so message isn't optional
public function __construct() {
// some code
$message = "<p><b>401 HTTP Error:</b> Error not authorized. Please check your Meetup API credentials</p>";
// make sure everything is assigned properly
parent::__construct($message, E_USER_ERROR, null);
}
// custom string representation of object
public function __toString() {
return __CLASS__ . ": {$this->message}\n";
}
}
class MeetupInternalServerErrorException extends Exception {
// Redefine the exception so message isn't optional
public function __construct() {
// some code
$message = "<p><b>500 HTTP Error:</b> Internal server error. The Meetup servers are currently experiencing difficulty</p>";
// make sure everything is assigned properly
parent::__construct($message, E_USER_ERROR, null);
}
// custom string representation of object
public function __toString() {
return __CLASS__ . ": {$this->message}\n";
}
}