Release 4.0.0-preview1-00051
[platform/core/csapi/tizenfx.git] / src / Tizen.Uix.SttEngine / Tizen.Uix.SttEngine / ExceptionFactory.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 static Interop.SttEngine;
19
20
21 namespace Tizen.Uix.SttEngine
22 {
23     internal static class ExceptionFactory
24     {
25         internal static Exception CreateException(ErrorCode err)
26         {
27             Tizen.Log.Error(LogTag, "Error " + err);
28             Exception exp;
29             switch (err)
30             {
31                 case ErrorCode.OutOfMemory:
32                 {
33                     exp = new OutOfMemoryException("Out Of Memory");
34                     break;
35                 }
36
37                 case ErrorCode.IoError:
38                 {
39                     exp = new InvalidOperationException("I/O Error Occured");
40                     break;
41                 }
42
43                 case ErrorCode.InvalidParameter:
44                 {
45                     exp = new ArgumentException("Invalid Parameters Provided");
46                     break;
47                 }
48
49                 case ErrorCode.NetworkDown:
50                 {
51                     exp = new InvalidOperationException("Network down(Out of network)");
52                     break;
53                 }
54
55                 case ErrorCode.InvalidState:
56                 {
57                     exp = new InvalidOperationException("Invalid state");
58                     break;
59                 }
60
61                 case ErrorCode.InvalidLanguage:
62                 {
63                     exp = new InvalidOperationException("Invalid language");
64                     break;
65                 }
66
67                 case ErrorCode.OperationFailed:
68                 {
69                     exp = new InvalidOperationException("Operation Failed");
70                     break;
71                 }
72
73                 case ErrorCode.NotSupportedFeature:
74                 {
75                     exp = new InvalidOperationException("Not supported feature");
76                     break;
77                 }
78
79                 case ErrorCode.NotSupported:
80                 {
81                     exp = new NotSupportedException("Not supported");
82                     break;
83                 }
84
85                 case ErrorCode.PermissionDenied:
86                 {
87                     exp = new UnauthorizedAccessException("Permission Denied");
88                     break;
89                 }
90
91                 case ErrorCode.RecordingTimedOut:
92                 {
93                     exp = new TimeoutException("Recording timed out");
94                     break;
95                 }
96
97                 default:
98                 {
99                     exp = new Exception("");
100                     break;
101                 }
102             }
103
104             return exp;
105         }
106     }
107 }