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.
18 using Tizen.Internals.Errors;
20 namespace Tizen.Messaging.Messages
22 internal enum MessagesError
24 None = ErrorCode.None,
25 OutOfMemory = ErrorCode.OutOfMemory,
26 InvalidParameter = ErrorCode.InvalidParameter,
27 ServerNotReady = -0x01710000 | 0x501,
28 CommunicationWithServerFailed = -0x01710000 | 0x502,
29 OutOfRange = -0x01710000 | 0x503,
30 SendingFailed = -0x01710000 | 0x504,
31 OperationFailed = -0x01710000 | 0x505,
32 NoSimCard = -0x01710000 | 0x506,
33 NoData = -0x01710000 | 0x507,
34 PermissionDenied = ErrorCode.PermissionDenied,
35 NotSupported = ErrorCode.NotSupported
38 internal static class MessagesErrorFactory
40 static internal void ThrowMessagesException(int e)
42 ThrowException(e, false);
45 static internal void ThrowMessagesException(int e, IntPtr handle)
47 ThrowException(e, (handle == IntPtr.Zero));
50 static private void ThrowException(int e, bool isHandleNull)
52 MessagesError err = (MessagesError)e;
56 throw new InvalidOperationException("Invalid instance (object may have been disposed or release)");
61 case MessagesError.OutOfMemory:
62 throw new OutOfMemoryException(err.ToString());
63 case MessagesError.InvalidParameter:
64 throw new ArgumentException(err.ToString());
65 case MessagesError.PermissionDenied:
66 throw new UnauthorizedAccessException(err.ToString());
67 case MessagesError.NotSupported:
68 throw new NotSupportedException(err.ToString());
70 throw new InvalidOperationException(err.ToString());