4
4
5
5
use MailQ \Exceptions \MailQException ;
6
6
use MailQ \Exceptions \UnresolvedMxDomainException ;
7
+ use MailQ \Exceptions \InvalidEmailAddressException ;
7
8
8
9
class Connector {
9
10
@@ -90,7 +91,7 @@ private function createResponse($ch,$response) {
90
91
function processError (Response $ responseData ,$ response ) {
91
92
switch ($ responseData ->getHttpCode ()) {
92
93
case 401 : throw new MailQException ("Invalid API key. " ,$ responseData ->getHttpCode ());
93
- case 405 : throw new MailQException (" Method not allowed. " ,$ responseData ->getHttpCode ());
94
+ case 405 : throw new MailQException ("Method not allowed. " ,$ responseData ->getHttpCode ());
94
95
default : $ this ->handleDefaultException ($ responseData ,$ response );
95
96
}
96
97
}
@@ -103,14 +104,18 @@ private function handleDefaultException(Response $responseData,$response) {
103
104
}
104
105
}
105
106
else {
106
- throw new MailQException ("Unknonw exception " ,$ responseData ->getHttpCode ());
107
+ throw new MailQException ("Unknown exception " ,$ responseData ->getHttpCode ());
107
108
}
108
109
}
109
110
110
111
private function createSpecificException ($ errorData ) {
111
- if ($ errorData ->message == 'Could not resolve MX domain. ' ) {
112
+ // TODO change to resolving messages by errorCode
113
+ if ($ errorData ->message === 'Could not resolve MX domain. ' ) {
112
114
throw new UnresolvedMxDomainException ($ errorData ->message ,$ errorData ->code );
113
115
}
116
+ else if ($ errorData ->message === 'Invalid recipient email. ' ) {
117
+ throw new InvalidEmailAddressException ($ errorData ->message ,$ errorData ->code );
118
+ }
114
119
else {
115
120
throw new MailQException ($ errorData ->message ,$ errorData ->code );
116
121
}
0 commit comments