Release 4.0.0-preview1-00172
[platform/core/csapi/tizenfx.git] / src / Tizen.Applications.Shortcut / Tizen.Applications.Shortcut / ShortcutErrorFactory.cs
1 /*
2  * Copyright (c) 2017 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 namespace Tizen.Applications.Shortcut
18 {
19     using System;
20
21     internal static class ShortcutErrorFactory
22     {
23         private const string LogTag = "Tizen.Applications.Shortcut";
24
25         internal static Exception GetException(Interop.Shortcut.ErrorCode err, string msg)
26         {
27             switch (err)
28             {
29                 case Interop.Shortcut.ErrorCode.InvalidParameter:
30                     return new ArgumentException(err + " error occurred.");
31                 case Interop.Shortcut.ErrorCode.PermissionDenied:
32                     return new UnauthorizedAccessException(err + " Permission denied (http://tizen.org/privilege/shortcut)");
33                 case Interop.Shortcut.ErrorCode.NotSupported:
34                     return new NotSupportedException(err + " Not Supported (http://tizen.org/feature/shortcut)");
35                 case Interop.Shortcut.ErrorCode.OutOfMemory:
36                     return new OutOfMemoryException(err + " error occurred.");
37                 default:
38                     Log.Error(LogTag, msg);
39                     return new InvalidOperationException(err + " error occurred.");
40             }
41         }
42     }
43 }