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 RecorderError
25 TizenErrorRecorder = -0x01950000,
26 RecorderErrorClass = TizenErrorRecorder | 0x10,
27 None = ErrorCode.None,
28 InvalidParameter = ErrorCode.InvalidParameter,
29 InvalidState = RecorderErrorClass | 0x02,
30 OutOfMemory = ErrorCode.OutOfMemory,
31 DeviceError = RecorderErrorClass | 0x04,
32 InvalidOperation = ErrorCode.InvalidOperation,
33 SecurityRestricted = RecorderErrorClass | 0x07,
34 Esd = RecorderErrorClass | 0x0a,
35 OutOfStorage = RecorderErrorClass | 0x0b,
36 PermissionDenied = ErrorCode.PermissionDenied,
37 NotSupported = ErrorCode.NotSupported,
38 ResourceConflict = RecorderErrorClass | 0x0c,
39 ServiceDisconnected = RecorderErrorClass | 0x0d
42 internal static class RecorderErrorFactory
44 internal static void ThrowIfError(RecorderError errorCode, string errorMessage = null,
45 [CallerMemberName] string caller = null, [CallerLineNumber] int line = 0)
47 if (errorCode == RecorderError.None)
52 Log.Info(RecorderLog.Tag, "errorCode : " + errorCode.ToString() + ", Caller : " + caller + ", line " + line.ToString());
56 case RecorderError.InvalidParameter:
57 throw new ArgumentException(errorMessage);
59 case RecorderError.OutOfMemory:
60 throw new OutOfMemoryException(errorMessage);
62 case RecorderError.DeviceError:
63 case RecorderError.Esd:
64 case RecorderError.SecurityRestricted:
65 case RecorderError.PermissionDenied:
66 throw new UnauthorizedAccessException(errorMessage);
68 case RecorderError.NotSupported:
69 throw new NotSupportedException(errorMessage);
71 case RecorderError.InvalidState:
72 case RecorderError.InvalidOperation:
73 case RecorderError.ResourceConflict:
74 case RecorderError.ServiceDisconnected:
75 case RecorderError.OutOfStorage: //TODO need to alloc new proper exception class
76 throw new InvalidOperationException(errorMessage);
79 throw new Exception("Unknown error : " + errorCode.ToString());