-
Notifications
You must be signed in to change notification settings - Fork 20
/
Copy pathServiceException.php
80 lines (69 loc) · 1.8 KB
/
ServiceException.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
75
76
77
78
79
80
<?php
namespace Honeybadger\Exceptions;
use Exception;
use Throwable;
class ServiceException extends Exception
{
/**
* @return ServiceException
*/
public static function invalidApiKey(): self
{
return new static('The API key provided is invalid.');
}
/**
* @return ServiceException
*/
public static function invalidPayload(): self
{
return new static('The payload sent to Honeybadger was invalid.');
}
/**
* @return ServiceException
*/
public static function rateLimit(): self
{
return new static('You have hit your exception rate limit.');
}
/**
* @return ServiceException
*/
public static function serverError(): self
{
return new static('There was an error on our end.');
}
/**
* @param int $code
* @return ServiceException
*/
public static function unexpectedResponseCode(int $code): self
{
return new static("Unexpected HTTP response code: $code");
}
/**
* @param Throwable|null $e
* @return self
*/
public static function generic(Throwable $e = null): self
{
$message = $e
? 'There was an error sending the payload to Honeybadger: '.$e->getMessage()
: 'There was an error sending the payload to Honeybadger.';
return new static($message, 0, $e);
}
/**
* @param string $message
* @return self
*/
public static function invalidConfig(string $message): self
{
return new static("The configuration is invalid: $message");
}
/**
* @return self
*/
public static function missingPersonalAuthToken(): self
{
return new static("Missing personal auth token. This token is required to use Honeybadger's Data APIs.");
}
}