Skip to content

Commit

Permalink
Fix error message behavior for base64 native
Browse files Browse the repository at this point in the history
  • Loading branch information
imalsogreg committed Sep 11, 2023
1 parent 56c856d commit 9224829
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
4 changes: 3 additions & 1 deletion src/Pact/Native.hs
Original file line number Diff line number Diff line change
Expand Up @@ -1415,7 +1415,9 @@ base64decode = defRNative "base64-decode" go
-- Use Legacy error behavior when 4.9 is disabled.
base64Behavior <- bool Simplified Legacy <$> isExecutionFlagSet FlagDisablePact49
parseResult <- base64DecodeWithShimmedErrors (getInfo i) base64Behavior s
case parseResult of
let
parseResultErrorContext = first ("Could not decode string: " <>) $ parseResult
case parseResultErrorContext of
Right bs -> case T.decodeUtf8' bs of
Right t -> return $ tStr t
Left _unicodeError -> evalError' i $ "invalid unicode"
Expand Down
2 changes: 1 addition & 1 deletion tests/pact/base64.repl
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@

(expect-failure
"base64 decoding fails on non base64-encoded input"
"invalid padding near offset 16"
"Could not decode string"
(base64-decode "aGVsbG8gd29ybGQh%"))

(expect-failure
Expand Down

0 comments on commit 9224829

Please sign in to comment.