Added TimeChanged get value API and modified exception.
[platform/core/csapi/system-settings.git] / Tizen.System.SystemSettings / Tizen.System.SystemSettings / SystemSettingsExceptionFactory.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
19 namespace Tizen.System
20 {
21     internal enum SystemSettingsError
22     {
23         None = Tizen.Internals.Errors.ErrorCode.None,
24         InvalidParameter = Tizen.Internals.Errors.ErrorCode.InvalidParameter,
25         OutOfMemory = Tizen.Internals.Errors.ErrorCode.OutOfMemory,
26         IoError = Tizen.Internals.Errors.ErrorCode.IoError,
27         PermissionDenied = Tizen.Internals.Errors.ErrorCode.PermissionDenied,
28         NotSupported = Tizen.Internals.Errors.ErrorCode.NotSupported,
29         LockScreenAppPasswordMode = -0x01140000 | 0x01
30     };
31     internal class SystemSettingsExceptionFactory
32     {
33         internal const string LogTag = "Tizen.System.SystemSettings";
34
35         internal static Exception CreateException(SystemSettingsError err, string msg)
36         {
37             Exception exp;
38             switch (err)
39             {
40                 case SystemSettingsError.InvalidParameter:
41                     exp = new ArgumentException(msg);
42                     break;
43                 case SystemSettingsError.NotSupported:
44                     exp = new NotSupportedException(msg);
45                     break;
46                 case SystemSettingsError.OutOfMemory:
47                 //fall through
48                 case SystemSettingsError.IoError:
49                 //fall through
50                 case SystemSettingsError.PermissionDenied:
51                 //fall through
52                 case SystemSettingsError.LockScreenAppPasswordMode:
53                 //fall through
54                 default:
55                     exp = new InvalidOperationException(msg);
56                     break;
57             }
58             return exp;
59         }
60     }
61 }