// Authors:
// Jonathan Pryor (jonpryor@vt.edu)
//
-// (C) 2004 Jonathan Pryor
+// (C) 2004-2005 Jonathan Pryor
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
[Serializable]
public class UnixIOException : IOException
{
+ private int errno;
+
public UnixIOException ()
: this (Marshal.GetLastWin32Error())
{}
- public UnixIOException (int error)
+ public UnixIOException (int errno)
+ : base (GetMessage (Native.NativeConvert.ToErrno (errno)))
{
- this.error = error;
+ this.errno = errno;
}
- public UnixIOException (int error, Exception inner)
- : base ("Unix-generated exception", inner)
+ public UnixIOException (int errno, Exception inner)
+ : base (GetMessage (Native.NativeConvert.ToErrno (errno)), inner)
+ {
+ this.errno = errno;
+ }
+
+ public UnixIOException (Native.Errno errno)
+ : base (GetMessage (errno))
{
- this.error = error;
+ this.errno = Native.NativeConvert.FromErrno (errno);
}
- public UnixIOException (Error error)
+ public UnixIOException (Native.Errno errno, Exception inner)
+ : base (GetMessage (errno), inner)
{
- this.error = UnixConvert.FromError (error);
+ this.errno = Native.NativeConvert.FromErrno (errno);
}
- public UnixIOException (Error error, Exception inner)
- : base ("Unix-generated exception", inner)
+ public UnixIOException (string message)
+ : base (message)
{
- this.error = UnixConvert.FromError (error);
+ this.errno = 0;
+ }
+
+ public UnixIOException (string message, Exception inner)
+ : base (message, inner)
+ {
+ this.errno = 0;
}
protected UnixIOException (SerializationInfo info, StreamingContext context)
}
public int NativeErrorCode {
- get {return error;}
+ get {return errno;}
}
- public Error ErrorCode {
- get {return UnixConvert.ToError (error);}
+ public Native.Errno ErrorCode {
+ get {return Native.NativeConvert.ToErrno (errno);}
}
- private int error;
-
- public override string ToString ()
+ private static string GetMessage (Native.Errno errno)
{
- return UnixMarshal.GetErrorDescription (ErrorCode);
+ return string.Format ("{0} [{1}].",
+ UnixMarshal.GetErrorDescription (errno),
+ errno);
}
}
}