Release 4.0.0-preview1-00051
[platform/core/csapi/tizenfx.git] / src / Tizen.Security.TEEC / Interop / Interop.Errors.cs
1 /*
2  * Interop.Errors.cs
3  *
4  *  Created on: Apr 4, 2017
5  *      Author: k.dynowski
6  */
7
8 using System;
9
10 internal static partial class Interop
11 {
12
13     private const string LogTag = "Tizen.Security.Libteec";
14     internal enum LibteecError : uint
15     {
16         None = 0,
17         NotImplemented = 0xFFFF0009,
18         CommunicationFailed = 0xFFFF000E,
19     };
20
21     internal static void CheckNThrowException(int err, string msg)
22     {
23         switch ((uint)err)
24         {
25             case (uint)LibteecError.None:
26                 return ;
27             case (uint)LibteecError.NotImplemented:
28                 throw new NotSupportedException(string.Format("[{0}] {1} error=0x{2}",
29                         LogTag, msg, err.ToString("X")));
30             case (uint)LibteecError.CommunicationFailed:
31                 throw new Exception(string.Format("[{0}] {1} error=0x{2}",
32                         LogTag, msg, err.ToString("X")));
33             default:
34                 throw new InvalidOperationException(string.Format("[{0}] {1}, error=0x{2}",
35                         LogTag, msg, err.ToString("X")));
36
37         }
38     }
39 }