8875b0f68b7928195290586008704873825454ef
[platform/core/csapi/tizenfx.git] / src / Tizen.Multimedia.Metadata / MetadataEditor / MetadataEditorErrorFactory.cs
1 /*
2 * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
3 *
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
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
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.
15 */
16
17
18 using System;
19 using System.IO;
20 using Tizen.Internals.Errors;
21
22 namespace Tizen.Multimedia
23 {
24     /// <summary>
25     /// Enumeration for metadata extractor's error codes.
26     /// </summary>
27     internal enum MetadataEditorError
28     {
29         None = ErrorCode.None,                          // Success
30         InvalidParameter = ErrorCode.InvalidParameter,  // Invalid parameter
31         OutOfMemory = ErrorCode.OutOfMemory,            // Out of memory
32         FileNotExists = ErrorCode.FileExists,              // File does not exist
33         PermissionDenied = ErrorCode.PermissionDenied,  // Permission deny
34         NotSupported = ErrorCode.NotSupported,          // Unsupported type
35         TizenMetadataEditorError = -0x019C0000,
36         OperationFailed = TizenMetadataEditorError | 0x01  // Invalid operation
37     };
38
39     internal static class MetadataEditorErrorFactory
40     {
41         internal static void ThrowIfError(MetadataEditorError errorCode, string errorMessage)
42         {
43             switch (errorCode)
44             {
45                 case MetadataEditorError.InvalidParameter:
46                     throw new ArgumentException(errorMessage);
47
48                 case MetadataEditorError.OutOfMemory:
49                     throw new OutOfMemoryException(errorMessage);
50
51                 case MetadataEditorError.FileNotExists:
52                     throw new FileNotFoundException(errorMessage);
53
54                 case MetadataEditorError.PermissionDenied:
55                     throw new UnauthorizedAccessException(errorMessage);
56
57                 case MetadataEditorError.NotSupported:
58                     throw new NotSupportedException(errorMessage);
59
60                 case MetadataEditorError.OperationFailed:
61                     throw new InvalidOperationException(errorMessage);
62             }
63         }
64     }
65 }
66