Ejemplo n.º 1
0
        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));
        }
Ejemplo n.º 2
0
        internal static void ThrowIfError(this ThumbnailExtractorError errorCode, string errorMessage)
        {
            if (errorCode == ThumbnailExtractorError.None)
            {
                return;
            }

            throw errorCode.ToException(errorMessage);
        }