-
Notifications
You must be signed in to change notification settings - Fork 4
/
ONIException.cs
39 lines (34 loc) · 1.1 KB
/
ONIException.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
using System;
using System.Runtime.InteropServices;
using System.Runtime.Serialization;
namespace oni
{
/// <summary>
/// Exception wrapper for error codes returned by the native ONI API.
/// </summary>
[Serializable]
public class ONIException : Exception
{
/// <summary>
/// The underlying ONI API error code.
/// </summary>
public readonly int Number;
protected ONIException() { }
/// <summary>
/// Initializes a new <see cref="oni.ONIException"/>
/// </summary>
/// <param name="errnum">The error code returned by the native ONI API.</param>
internal ONIException(int errnum)
{
Number = errnum;
}
/// <summary>
/// Get a human-readable version of the error code produced by the native ONI API.
/// </summary>
public override string Message =>
Marshal.PtrToStringAnsi(NativeMethods.oni_error_str(Number));
protected ONIException(SerializationInfo info, StreamingContext context)
: base(info, context)
{ }
}
}