public static int CameraErrorToErrorCode(CameraError error) { if (!Util.IsCapableOfRunning(10, 1) && error == CameraError.EALREADY) { return NativeConvert.FromErrno(Errno.EALREADY); } return (int)error; }
public static CameraError ErrorCodeToCameraError(int errorCode) { if (Util.IsCapableOfRunning(10, 1)) { if (errorCode == NativeConvert.FromErrno(Errno.EALREADY)) { errorCode = EALREADY_NEW; } } return (CameraError)errorCode; }
/// <summary> /// Get the exception to throw for errno. /// </summary> /// <param name="errno">The errno to get an exception for.</param> /// <param name="throwForGeneric">Throw exception for general, Mono supported exceptions.</param> /// <returns>The exeption to throw, or null if there was no exception.</returns> public static Exception GetExceptionForErrno(Errno errno, bool throwForGeneric = false) { if (NativeConvert.FromErrno(errno) == 0) { return(null); } switch (errno) { case Errno.ENOMEM: return(new OutOfMemoryException()); case Errno.EEXIST: return(new IOException("File already exists", NativeConvert.FromErrno(errno))); case Errno.EMFILE: return(new IOException("Too many files open", NativeConvert.FromErrno(errno))); case Errno.ENOTTY: return(new IOException("Inappropriate I/O control operation", NativeConvert.FromErrno(errno))); case Errno.EFBIG: return(new IOException("File too large", NativeConvert.FromErrno(errno))); case Errno.EPIPE: return(new PipeException("Broken pipe", NativeConvert.FromErrno(errno))); case ((Errno)47): //ECANCELED return(new OperationCanceledException()); case ((Errno)48): //ENOTSUP return(new NotSupportedException()); } if (throwForGeneric) { Mono.Unix.UnixMarshal.ThrowExceptionForError(errno); return(null); //Will never reach here } else { // Nasty hack to actually get exception try { Mono.Unix.UnixMarshal.ThrowExceptionForError(errno); return(new InvalidOperationException(Mono.Unix.UnixMarshal.GetErrorDescription(errno))); // Backup if no exception gets thrown. } catch (Exception e) { return(e); } } }
public UnixIOException(Errno errno, Exception inner) : base(UnixIOException.GetMessage(errno), inner) { this.errno = NativeConvert.FromErrno(errno); }