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 System.Collections.Generic;
22 namespace Tizen.System
24 internal enum DeviceError
26 None = Tizen.Internals.Errors.ErrorCode.None,
27 InvalidParameter = Tizen.Internals.Errors.ErrorCode.InvalidParameter,
28 PermissionDenied = Tizen.Internals.Errors.ErrorCode.PermissionDenied,
29 InvalidOperation = Tizen.Internals.Errors.ErrorCode.InvalidOperation,
30 AlreadyInProgress = Tizen.Internals.Errors.ErrorCode.NowInProgress,
31 NotSupported = Tizen.Internals.Errors.ErrorCode.NotSupported,
32 ResourceBusy = Tizen.Internals.Errors.ErrorCode.ResourceBusy,
33 OperationFailed = -0x01140000 | 0x01,
34 NotInitialized = -0x01140000 | 0x02
37 class DeviceExceptionFactory
39 internal const string LogTag = "Tizen.System.Device";
41 internal static Exception CreateException(DeviceError err, string msg)
46 case DeviceError.InvalidParameter:
47 case DeviceError.NotInitialized:
49 exp = new ArgumentException(msg);
51 case DeviceError.NotSupported:
52 exp = new NotSupportedException(msg +" : Device does not support the Operation.");
54 case DeviceError.AlreadyInProgress:
56 case DeviceError.ResourceBusy:
58 case DeviceError.OperationFailed:
60 case DeviceError.InvalidOperation:
61 exp = new InvalidOperationException(msg);
63 case DeviceError.PermissionDenied:
64 exp = new UnauthorizedAccessException(msg);
67 exp = new InvalidOperationException("Unknown error occured.");