Return a structured Image.Error from every open and write path - #218
Merged
kipcole9 merged 1 commit intoJul 28, 2026
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Image.open/2andImage.write/3now returns{:error, %Image.Error{}}.:operationis now set for all open and write errorsImage.open!/2would put the entire image into:path, and then interpolate it into:messageImage.Error.wrap/2, delegating the work toImage.Error.exception/1instead. This removes potential error message drift (which had already happened for:enoent)Image.Errortuple constructorsvix_open/2toopen_path/2for consistency with the newopen_binary/2andopen_enum/2functionsBreaking changes:
Image.from_binary/2returns{:error, %Image.Error{}}instead of{:error, binary}Image.write/3to aPlug.Connreturns%Image.Error{reason: :closed}rather than{:error, :closed}Image.Error.exception(reason: :enoent, path: p)now haswrap/2's message,"The image file ... was not found or could not be opened", instead of"File not found: ..."{atom, value}reason built throughImage.Error.wrap/2gains the "Image error: " prefixraise Image.Error, {:enoent, path}andraise Image.Error, {message, path}no longer have clauses and fall through to the catch-all (was documented behaviour)