diff options
author | 2015-02-21 21:58:36 -0700 | |
---|---|---|
committer | 2015-02-21 21:58:36 -0700 | |
commit | e1fddae3b6edbbd33a22408f30a36704906cd30f (patch) | |
tree | 95d7a0b3f33d03e2f8f46193af8b287f0a734fa7 /src/java/com/libmailcore/SMTPOperation.java | |
parent | 261fe679c7fb736dd3bd01c05871d7b4c5337bb6 (diff) | |
parent | 8a0df88bbb36804020111385a7aaed2c701a1944 (diff) |
Merge remote-tracking branch 'upstream/master'
Diffstat (limited to 'src/java/com/libmailcore/SMTPOperation.java')
-rw-r--r-- | src/java/com/libmailcore/SMTPOperation.java | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/src/java/com/libmailcore/SMTPOperation.java b/src/java/com/libmailcore/SMTPOperation.java new file mode 100644 index 00000000..3eecb792 --- /dev/null +++ b/src/java/com/libmailcore/SMTPOperation.java @@ -0,0 +1,33 @@ +package com.libmailcore; + +public class SMTPOperation extends Operation { + /** + Returns error once the operation finished running. It will return null if the operation + successfully ran. + */ + public MailException exception() { + if (errorCode() == ErrorCode.ErrorNone) { + return null; + } + return new MailException(errorCode()); + } + + private native int errorCode(); + + /** + Calls the method succeeded() of the callback if the operation succeeded or failed() + if the operation failed. + @see com.libmailcore.OperationCallback + */ + protected void callCallback() + { + if (callback != null) { + if (errorCode() == ErrorCode.ErrorNone) { + callback.succeeded(); + } + else { + callback.failed(exception()); + } + } + } +} |