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.Runtime.CompilerServices;
19 using Tizen.Internals.Errors;
21 namespace Tizen.Multimedia
23 internal enum CameraError
25 TizenErrorCamera = -0x01910000,
26 CameraErrorClass = TizenErrorCamera,
27 None = ErrorCode.None,
28 InvalidParameter = ErrorCode.InvalidParameter,
29 InvalidState = CameraErrorClass | 0x02,
30 OutOfMemory = ErrorCode.OutOfMemory,
31 DeviceError = CameraErrorClass | 0x04,
32 InvalidOperation = ErrorCode.InvalidOperation,
33 SecurityRestricted = CameraErrorClass | 0x07,
34 DeviceBusy = CameraErrorClass | 0x08,
35 DeviceNotFound = CameraErrorClass | 0x09,
36 Esd = CameraErrorClass | 0x0c,
37 PermissionDenied = ErrorCode.PermissionDenied,
38 NotSupported = ErrorCode.NotSupported,
39 ResourceConflict = CameraErrorClass | 0x0d,
40 ServiceDisconnected = CameraErrorClass | 0x0e
43 internal static class CameraErrorFactory
45 internal static void ThrowIfError(CameraError errorCode, string errorMessage = null,
46 [CallerMemberName] string caller = null, [CallerLineNumber] int line = 0)
48 if (errorCode == CameraError.None)
53 Log.Info(CameraLog.Tag, "errorCode : " + errorCode.ToString() + ", Caller : " + caller + ", line " + line.ToString());
57 case CameraError.InvalidParameter:
58 throw new ArgumentException(errorMessage);
60 case CameraError.OutOfMemory:
61 throw new OutOfMemoryException(errorMessage);
63 case CameraError.DeviceError:
64 case CameraError.DeviceBusy:
66 throw new CameraDeviceException(errorMessage);
68 case CameraError.DeviceNotFound:
69 throw new CameraDeviceNotFoundException(errorMessage);
71 case CameraError.SecurityRestricted:
72 case CameraError.PermissionDenied:
73 throw new UnauthorizedAccessException(errorMessage);
75 case CameraError.NotSupported:
76 throw new NotSupportedException(errorMessage);
78 case CameraError.InvalidState:
79 case CameraError.InvalidOperation:
80 case CameraError.ResourceConflict:
81 case CameraError.ServiceDisconnected:
82 throw new InvalidOperationException(errorMessage);
85 throw new Exception("Unknown error : " + errorCode);