Return an ok/error tuple from Image.average/1 and Image.chroma_color/1 - #219
Merged
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.average/1returned a bare list on success and{:error, reason}on failure, which made it awkward to use inwith/casestatements, having to guard onis_list/1or rely on clause ordering instead of matching on an:ok/:errortuple.Pixel.t()to[number()](and now wrapped in an:oktuple)Image.ErrorstructImage.chroma_color/1now returns{:ok, [number()]} | {:error, Image.Error.t()}since it returns the result ofImage.average/1Image.chroma_color!/1as a companion toImage.chroma_color/1average/1(using a truncated JPEG)chroma_mask/2andfind_trim/2now propagate a failed:autocolor lookup instead of using the error tuple as a pixelBreaking changes
Image.average/1returns{:ok, [number()]} | {:error, Image.Error.t()}when is_list(color)) should now match{:ok, color}instead{:ok, color}and{:error, reason}in any orderImage.Errorstructs instead ofbinary()Image.chroma_color/1returns{:ok, [number()]} | {:error, Image.Error.t()}Previously the spec claimed
Pixel.t()with no error case, which was inaccurate, as all offlatten/2,crop/5andaverage/1could return an error tuple.