Selaa lähdekoodia

Unifying error

Pascal Peridont 19 vuotta sitten
vanhempi
commit
a38875c7f2
3 muutettua tiedostoa jossa 7 lisäystä ja 14 poistoa
  1. 1 1
      std/mtwin/mail/Exception.hx
  2. 1 1
      std/mtwin/mail/Imap.hx
  3. 5 12
      std/mtwin/mail/Smtp.hx

+ 1 - 1
std/mtwin/mail/Exception.hx

@@ -1,6 +1,6 @@
 package mtwin.mail;
 package mtwin.mail;
 
 
-class Exception {
+enum Exception {
 	ConnectionError(host:String,port:Int);
 	ConnectionError(host:String,port:Int);
 	SmtpMailFromError(e:String);
 	SmtpMailFromError(e:String);
 	SmtpRcptToError(e:String);
 	SmtpRcptToError(e:String);

+ 1 - 1
std/mtwin/mail/Imap.hx

@@ -1,5 +1,6 @@
 package mtwin.mail;
 package mtwin.mail;
 
 
+import neko.Socket;
 import mtwin.mail.Exception;
 import mtwin.mail.Exception;
 
 
 signature ImapConnectionInfo {
 signature ImapConnectionInfo {
@@ -15,7 +16,6 @@ signature ImapMailbox {
 	hasChildren: Bool
 	hasChildren: Bool
 }
 }
 
 
-import neko.Socket;
 
 
 class Imap {
 class Imap {
 	public static var DEBUG = false;
 	public static var DEBUG = false;

+ 5 - 12
std/mtwin/mail/Smtp.hx

@@ -1,14 +1,7 @@
 package mtwin.mail;
 package mtwin.mail;
 
 
 import neko.Socket;
 import neko.Socket;
-
-enum SmtpException extends mtwin.mail.Exception {
-	ConnectionError(host:String,port:Int);
-	MailFromError(e:String);
-	RcptToError(e:String);
-	DataError(e:String);
-	SendDataError;
-}
+import mtwin.mail.Exception;
 
 
 class Smtp {
 class Smtp {
 
 
@@ -28,21 +21,21 @@ class Smtp {
 		var ret = StringTools.trim(cnx.readLine());
 		var ret = StringTools.trim(cnx.readLine());
 		if( ret.substr(0,3) != "250" ){
 		if( ret.substr(0,3) != "250" ){
 			cnx.close();
 			cnx.close();
-			throw MailFromError(ret);
+			throw SmtpMailFromError(ret);
 		}
 		}
 
 
 		cnx.write( "RCPT TO:<" + to + ">\r\n" );
 		cnx.write( "RCPT TO:<" + to + ">\r\n" );
 		ret = StringTools.trim(cnx.readLine());
 		ret = StringTools.trim(cnx.readLine());
 		if( ret.substr(0,3) != "250" ){
 		if( ret.substr(0,3) != "250" ){
 			cnx.close();
 			cnx.close();
-			throw RcptToError(ret);
+			throw SmtpRcptToError(ret);
 		}
 		}
 
 
 		cnx.write( "DATA\r\n" );
 		cnx.write( "DATA\r\n" );
 		ret = StringTools.trim(cnx.readLine());
 		ret = StringTools.trim(cnx.readLine());
 		if( ret.substr(0,3) != "354" ){
 		if( ret.substr(0,3) != "354" ){
 			cnx.close();
 			cnx.close();
-			throw DataError(ret);
+			throw SmtpDataError(ret);
 		}
 		}
 
 
 		if( data.substr(data.length -2,2) != "\r\n" ) 
 		if( data.substr(data.length -2,2) != "\r\n" ) 
@@ -52,7 +45,7 @@ class Smtp {
 		ret = StringTools.trim(cnx.readLine());
 		ret = StringTools.trim(cnx.readLine());
 		if( ret.substr(0,3) != "250" ){
 		if( ret.substr(0,3) != "250" ){
 			cnx.close();
 			cnx.close();
-			throw SendDataError;
+			throw SmtpSendDataError;
 		}
 		}
 
 
 		cnx.write( "QUIT\r\n" );
 		cnx.write( "QUIT\r\n" );