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.Multimedia
22 internal enum StreamRecorderError
24 None = ErrorCode.None,
25 InvalidParameter = ErrorCode.InvalidParameter,
26 TizenErrorStreamRecorder = -0x01A10000,
27 InvalidState = TizenErrorStreamRecorder | 0x01,
28 OutOfMemory = ErrorCode.OutOfMemory,
29 InvalidOperation = ErrorCode.InvalidOperation,
30 OutOfStorage = TizenErrorStreamRecorder | 0x02,
31 PermissionDenied = ErrorCode.PermissionDenied,
32 NotSupported = ErrorCode.NotSupported,
35 internal static class StreamRecorderErrorFactory
37 internal static void ThrowException(int errorCode, string errorMessage = null, string paramName = null)
39 StreamRecorderError err = (StreamRecorderError)errorCode;
40 if (string.IsNullOrEmpty(errorMessage))
42 errorMessage = err.ToString();
44 switch ((StreamRecorderError)errorCode)
46 case StreamRecorderError.InvalidParameter:
47 throw new ArgumentException(errorMessage, paramName);
48 case StreamRecorderError.OutOfMemory:
49 throw new OutOfMemoryException(errorMessage);
50 case StreamRecorderError.PermissionDenied:
51 throw new UnauthorizedAccessException(errorMessage);
52 case StreamRecorderError.NotSupported:
53 throw new NotSupportedException(errorMessage);
54 case StreamRecorderError.InvalidState:
55 case StreamRecorderError.InvalidOperation:
56 case StreamRecorderError.OutOfStorage:
57 throw new InvalidOperationException(errorMessage);