Avoid swallowing errors in case of AttachmentType Serialization failure #1953
+22
−8
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Given that this TODO has been here since the inception of the system, and that I've seen quite a few errors get swallowed, I figured it was time to tackle this.
The change itself is trivial, but going through
DataResult#getOrThrow
rather than first obtaining theOptional
and then unconditionally unwrapping it gives us access to the error message that signals the issue within the codec, so the developer has a better idea of what's going on.It would be better if we were to somehow also be able to print the ID or some other kind of identifying info to specifically indicate which attachment is exploding, but that does not seem to be possible with the system as it is currently designed. For this reason, I decided to leave that temporarily as a further TODO for discussion.