internal static Exception ToException(this ThumbnailExtractorError errorCode, string errorMessage) { switch (errorCode) { case ThumbnailExtractorError.InvalidParameter: return(new ArgumentException(errorMessage)); case ThumbnailExtractorError.OutOfMemory: return(new OutOfMemoryException(errorMessage)); case ThumbnailExtractorError.InvalidOperation: return(new InvalidOperationException(errorMessage)); case ThumbnailExtractorError.FileNoSpaceOnDevice: return(new IOException("No space to write on the device.")); case ThumbnailExtractorError.PermissionDenied: return(new UnauthorizedAccessException("[" + errorCode.ToString() + "]" + errorMessage)); case ThumbnailExtractorError.UnsupportedContent: return(new FileFormatException(errorMessage)); } return(new InvalidOperationException("[" + errorCode.ToString() + "]" + errorMessage)); }
internal static void ThrowIfError(this ThumbnailExtractorError errorCode, string errorMessage) { if (errorCode == ThumbnailExtractorError.None) { return; } throw errorCode.ToException(errorMessage); }