internal static void Success(uv_err_t error) { var e = Map(error); if (e != null) { throw e; } }
internal static Exception Map(uv_err_t error, string name = null) { if (error.code == uv_err_code.UV_OK) { return(null); } switch (error.code) { case uv_err_code.UV_EINVAL: return(new ArgumentException(error.Description)); 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)); default: return(new UVException(error)); } }
public void End(IntPtr ptr) { Exception e = null; if (Result.ToInt32() == -1) { uv_err_t err = new uv_err_t(Error); e = Ensure.Map(err, (string.IsNullOrEmpty(Path) ? null : Path)); } if (Callback != null) { Callback(e); } Dispose(); }
public void End(IntPtr ptr) { // good idea when you have only the pointer, but no need for it ... // var fsr = new FileSystemRequest(ptr, false).Value.Target as FileSystemRequest; Exception e = null; if (Result.ToInt32() == -1) { uv_err_t err = new uv_err_t(Error); Callback(Ensure.Map(err), null); } if (Callback != null) { Callback(e, this); } Dispose(); }
internal static Exception Map(uv_err_t error, string name = null) { if (error.code == uv_err_code.UV_OK) { return null; } switch (error.code) { case uv_err_code.UV_EINVAL: return new ArgumentException(error.Description); 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); default: return new UVException(error); } }
private static extern sbyte *uv_err_name(uv_err_t error);
private static extern sbyte *uv_strerror(uv_err_t error);
internal UVException(uv_err_t error) : this((int)error.code, error.Name, error.Description) { }