internal static OperationException CreateError(uv_err_code error) { string name = GetErrorName(error); string description = GetErrorDescription(error); return(new OperationException((int)error, name, description)); }
internal static Exception Map(uv_err_code error, string name = null) { if (error == uv_err_code.UV_OK) { return(null); } switch (error) { case uv_err_code.UV_EINVAL: return(new ArgumentException(UVException.StringError(error))); case uv_err_code.UV_ENOENT: var path = (name == null ? System.IO.Directory.GetCurrentDirectory() : Path.Combine(System.IO.Directory.GetCurrentDirectory(), name)); return(new System.IO.FileNotFoundException(string.Format("Could not find file '{0}'.", path), path)); case uv_err_code.UV_EADDRINUSE: return(new SocketException(10048)); case uv_err_code.UV_EADDRNOTAVAIL: return(new SocketException(10049)); case uv_err_code.UV_ECONNREFUSED: return(new SocketException(10061)); case uv_err_code.UV_ENOTSUP: return(new NotSupportedException()); default: return(new UVException(error)); } }
internal static string GetErrorName(uv_err_code error) { IntPtr ptr = uv_err_name(error); string name = ptr != IntPtr.Zero ? Marshal.PtrToStringAnsi(ptr) : null; return(name); }
private static string GetErrorName(uv_err_code code) { IntPtr ptr = uv_err_name(code); if (ptr == IntPtr.Zero) { return(null); } return(Marshal.PtrToStringAnsi(ptr)); }
private static string GetErrorDescription(uv_err_code code) { IntPtr ptr = uv_strerror(code); if (ptr == IntPtr.Zero) { return(null); } return(Marshal.PtrToStringAnsi(ptr)); }
internal static OperationException CreateError(uv_err_code error) { IntPtr ptr = uv_err_name(error); string name = ptr != IntPtr.Zero ? Marshal.PtrToStringAnsi(ptr) : null; ptr = uv_strerror(error); string description = ptr != IntPtr.Zero ? Marshal.PtrToStringAnsi(ptr) : null; return(new OperationException((int)error, name, description)); }
internal static string StringError(uv_err_code error) { return(StringError((int)error)); }
internal UVException(uv_err_code errorCode) : this((int)errorCode) { }
private static extern IntPtr uv_err_name(uv_err_code err);
private static extern IntPtr uv_strerror(uv_err_code err);
internal static void ThrowOperationException(uv_err_code error) => throw CreateError(error);
static string GetErrorName(uv_err_code code) { IntPtr ptr = uv_err_name(code); return(ptr == IntPtr.Zero ? null : Marshal.PtrToStringAnsi(ptr)); }
static string GetErrorDescription(uv_err_code code) { IntPtr ptr = uv_strerror(code); return(ptr == IntPtr.Zero ? null : Marshal.PtrToStringAnsi(ptr)); }
public static extern IntPtr uv_err_name(uv_err_code err);
public static extern IntPtr uv_strerror(uv_err_code err);
public uv_err_t(int error) { code = (uv_err_code)error; sys_errno_ = 0; }