Add EditorBrowsable attribute for internal components
[platform/core/csapi/tizenfx.git] / src / Tizen.System.Information / RuntimeInfo / RuntimeInfoErrorFactory.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 using System;
18 using System.ComponentModel;
19 using Tizen.Internals.Errors;
20
21 namespace Tizen.System
22 {
23     [EditorBrowsable(EditorBrowsableState.Never)]
24     internal enum RuntimeInfoError
25     {
26         None = ErrorCode.None,
27         InvalidParameter = ErrorCode.InvalidParameter,
28         OutOfMemory = ErrorCode.OutOfMemory,
29         Io = ErrorCode.IoError,
30         RemoteIo = ErrorCode.RemoteIo,
31         PermissionDenied = ErrorCode.PermissionDenied,
32         NotSupported = ErrorCode.NotSupported,
33         NoData = ErrorCode.NoData
34     }
35
36     [EditorBrowsable(EditorBrowsableState.Never)]
37     internal static class RuntimeInfoErrorFactory
38     {
39         internal const string LogTag = "Tizen.System.RuntimeInformation";
40
41         internal static void ThrowException(int err)
42         {
43             RuntimeInfoError error = (RuntimeInfoError)err;
44             if (error == RuntimeInfoError.InvalidParameter)
45             {
46                 throw new ArgumentException("Invalid parameter");
47             }
48             else if (error == RuntimeInfoError.OutOfMemory)
49             {
50                 throw new OutOfMemoryException("Out of memory");
51             }
52             else if (error == RuntimeInfoError.Io)
53             {
54                 throw new ArgumentException("I/O Error");
55             }
56             else if (error == RuntimeInfoError.RemoteIo)
57             {
58                 throw new ArgumentException("Remote I/O Error");
59             }
60             else if (error == RuntimeInfoError.PermissionDenied)
61             {
62                 throw new UnauthorizedAccessException("Permission denied");
63             }
64             else if (error == RuntimeInfoError.NotSupported)
65             {
66                 throw new NotSupportedException("Not supported");
67             }
68             else if (error == RuntimeInfoError.NoData)
69             {
70                 throw new NotSupportedException("No data");
71             }
72         }
73     }
74 }