Skip to content

Dont throw the exception in the code #530

Closed

Description

@lindexi
    catch (Exception err)
    {
        switch (err.HResult)
        {
            case unchecked((int)0x88982F81): //WINCODEC_ERR_UNSUPPORTEDOPERATION
                                             // If the encoder does not support writing a thumbnail, then try again
                                             // but disable thumbnail generation.
                encoder.IsThumbnailGenerated = false;
                break;
            default:
                throw err;
        }
    }

You can see the code throw the err in switch that should rethrow possibility intended.

Suggestion:

            try
            {
                await encoder.FlushAsync();
            }
            catch (Exception exception)
            {
                const int WINCODEC_ERR_UNSUPPORTEDOPERATION = unchecked((int) 0x88982F81);

                switch (exception.HResult)
                {
                    case WINCODEC_ERR_UNSUPPORTEDOPERATION:
                        // If the encoder does not support writing a thumbnail, then try again
                        // but disable thumbnail generation.
                        encoder.IsThumbnailGenerated = false;
                        break;
                    default:
                        throw;
                }
            }

Document Details

⚠ Do not edit this section. It is required for docs.microsoft.com ➟ GitHub issue linking.

Activity

  1. laurenhughes commented on Jun 5, 2018

    @laurenhughes
    Contributor

    Thank you for the suggestion, lindexi (@lindexi). I'll get the sample updated!

  2. added a commit that references this issue on Jan 22, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions