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.
20 using Tizen.Internals.Errors;
22 namespace Tizen.Content.MediaContent
25 /// Enumeration for media content's error code
27 /// <since_tizen> 3 </since_tizen>
28 /// <remarks><paramref name="NotSupported"/> error occurs when the device does not support the function.</remarks>
29 public enum MediaContentError
31 None = ErrorCode.None,
32 InvalidParameter = ErrorCode.InvalidParameter,
33 OutOfMemory = ErrorCode.OutOfMemory,
34 InvalidOperation = ErrorCode.InvalidOperation,
35 FileNoSpaceOnDevice = ErrorCode.FileNoSpaceOnDevice,
36 PermissionDenied = ErrorCode.PermissionDenied,
37 TizenMediaContentError = -0x01610000,
38 DatabaseFailed = TizenMediaContentError | 0x01,
39 DatabaseBusy = TizenMediaContentError | 0x02,
40 NetworkFailed = TizenMediaContentError | 0x03,
41 UnsupportedContent = TizenMediaContentError | 0x04,
42 NotSupported = ErrorCode.NotSupported,
45 internal class MediaContentValidator
47 internal const string LogTag = "Tizen.Content.MediaContent";
49 internal static void ThrowIfError(MediaContentError err, string msg)
53 case MediaContentError.InvalidParameter:
54 throw new ArgumentException(msg);
55 case MediaContentError.OutOfMemory:
56 throw new OutOfMemoryException(msg);
57 case MediaContentError.InvalidOperation:
58 throw new InvalidOperationException(msg);
59 case MediaContentError.FileNoSpaceOnDevice:
60 throw new IOException(msg);
61 case MediaContentError.PermissionDenied:
62 throw new UnauthorizedAccessException(msg);
63 case MediaContentError.DatabaseFailed:
64 throw new InvalidOperationException("[DB Failed]" + msg);
65 case MediaContentError.DatabaseBusy:
66 throw new InvalidOperationException("[DB Busy]" + msg);
67 case MediaContentError.NetworkFailed:
68 throw new InvalidOperationException("[Network Error]" + msg);
69 case MediaContentError.UnsupportedContent:
70 throw new PlatformNotSupportedException(msg);
74 internal static string CheckString(string value)
76 return (value != null) ? value : "";