2 * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
19 using Tizen.Internals.Errors;
21 namespace Tizen.Messaging.Email
23 internal enum EmailError
25 None = ErrorCode.None,
26 OutOfMemory = ErrorCode.OutOfMemory,
27 InvalidParameter = ErrorCode.InvalidParameter,
28 ServerNotReady = -0x01710000 | 0x501,
29 CommunicationWithServerFailed = -0x01710000 | 0x502,
30 OutOfRange = -0x01710000 | 0x503,
31 SendingFailed = -0x01710000 | 0x504,
32 OperationFailed = -0x01710000 | 0x505,
33 NoSimCard = -0x01710000 | 0x506,
34 NoData = -0x01710000 | 0x507,
35 PermissionDenied = ErrorCode.PermissionDenied,
36 NotSupported = ErrorCode.NotSupported
39 internal static class EmailErrorFactory
41 internal const string LogTag = "Tizen.Messaging.Email";
43 internal static Exception GetException(int err)
45 EmailError error = (EmailError)err;
46 if (error == EmailError.OutOfMemory)
48 return new OutOfMemoryException("Out of memory");
50 else if (error == EmailError.InvalidParameter)
52 return new ArgumentException("Invalid parameter");
54 else if (error == EmailError.ServerNotReady)
56 return new IOException("Server not ready yet"); ;
58 else if (error == EmailError.NoData)
60 return new InvalidDataException("No data found");
62 else if (error == EmailError.CommunicationWithServerFailed)
64 return new TimeoutException("timed out");
66 else if (error == EmailError.PermissionDenied)
68 return new UnauthorizedAccessException("Permission denied");
70 else if (error == EmailError.NotSupported)
72 return new NotSupportedException("Not supported");
74 else if (error == EmailError.OutOfRange)
76 return new IndexOutOfRangeException("Out of range");
78 else if (error == EmailError.SendingFailed)
80 return new Exception("Sending failed");
82 else if (error == EmailError.OperationFailed)
84 return new InvalidOperationException("operation failed");
86 else if (error == EmailError.NoSimCard)
88 return new Exception("No sim card found");
92 return new Exception("System operation");