• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2008 The Android Open Source Project
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 package com.android.email.mail;
18 
19 /**
20  * This exception is used for most types of failures that occur during server interactions.
21  *
22  * Data passed through this exception should be considered non-localized.  Any strings should
23  * either be internal-only (for debugging) or server-generated.
24  *
25  * TO DO: Does it make sense to further collapse AuthenticationFailedException and
26  * CertificateValidationException and any others into this?
27  */
28 public class MessagingException extends Exception {
29     public static final long serialVersionUID = -1;
30 
31     public static final int NO_ERROR = -1;
32     /** Any exception that does not specify a specific issue */
33     public static final int UNSPECIFIED_EXCEPTION = 0;
34     /** Connection or IO errors */
35     public static final int IOERROR = 1;
36     /** The configuration requested TLS but the server did not support it. */
37     public static final int TLS_REQUIRED = 2;
38     /** Authentication is required but the server did not support it. */
39     public static final int AUTH_REQUIRED = 3;
40     /** General security failures */
41     public static final int GENERAL_SECURITY = 4;
42     /** Authentication failed */
43     public static final int AUTHENTICATION_FAILED = 5;
44     /** Attempt to create duplicate account */
45     public static final int DUPLICATE_ACCOUNT = 6;
46     /** Required security policies not supported */
47     public static final int SECURITY_POLICIES_REQUIRED = 7;
48 
49     protected int mExceptionType;
50 
MessagingException(String message)51     public MessagingException(String message) {
52         super(message);
53         mExceptionType = UNSPECIFIED_EXCEPTION;
54     }
55 
MessagingException(String message, Throwable throwable)56     public MessagingException(String message, Throwable throwable) {
57         super(message, throwable);
58         mExceptionType = UNSPECIFIED_EXCEPTION;
59     }
60 
61     /**
62      * Constructs a MessagingException with an exceptionType and a null message.
63      * @param exceptionType The exception type to set for this exception.
64      */
MessagingException(int exceptionType)65     public MessagingException(int exceptionType) {
66         super();
67         mExceptionType = exceptionType;
68     }
69 
70     /**
71      * Constructs a MessagingException with an exceptionType and a message.
72      * @param exceptionType The exception type to set for this exception.
73      */
MessagingException(int exceptionType, String message)74     public MessagingException(int exceptionType, String message) {
75         super(message);
76         mExceptionType = exceptionType;
77     }
78 
79     /**
80      * Return the exception type.  Will be OTHER_EXCEPTION if not explicitly set.
81      *
82      * @return Returns the exception type.
83      */
getExceptionType()84     public int getExceptionType() {
85         return mExceptionType;
86     }
87 }
88