Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

decodeStructure swallows exceptions #1187

Closed
jschneider opened this issue Nov 6, 2020 · 1 comment
Closed

decodeStructure swallows exceptions #1187

jschneider opened this issue Nov 6, 2020 · 1 comment
Assignees
Labels

Comments

@jschneider
Copy link

jschneider commented Nov 6, 2020

Exceptions thrown within the decodeStructure block are swallowed.

This code:

decoder.decodeStructure(descriptor) {
        TODO()
    }

throws an JsonDecodingException:
Unexpected JSON token at offset 1: Expected '}'

I assume the original exception is hidden, because the decoder tries to finish decoding the JSON object.

I strongly prefer to have the the original exception thrown.

@sandwwraith
Copy link
Member

I think the problem happens because decodeStructure always tries to finish structure in finally block:

finally {
        composite.endStructure(descriptor)
    }

AFAIR, exceptions thrown from finally block have higher priority, so the original exception is lost. And JSON decoder can't find closing brace because body hasn't been decoded, hence 'expected }'.

@sandwwraith sandwwraith added the bug label Nov 9, 2020
qwwdfsad added a commit that referenced this issue Nov 13, 2020
…n exception has been thrown, so the original exception will be propagated

Fixes #1187
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants