Skip to content

Commit

Permalink
add missing function
Browse files Browse the repository at this point in the history
  • Loading branch information
V-FEXrt committed Nov 8, 2023
1 parent 605b2ab commit 182f985
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
2 changes: 1 addition & 1 deletion json.wake
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package json

from wake import _
from utils import prefixError
from result import prefixError
from query import _

# Anyone who depends on json will also
Expand Down
17 changes: 17 additions & 0 deletions result.wake
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package result

# When `result` is Fail, prefixes the internal error message with `prefix`
#
# Parameters:
# - `prefix`: The message to prepend to `result`
# - `result`: The Result which may be prepended to
#
# Examples:
# ```
# prefixError "foo" (Pass 123) -> Pass 123
# prefixError "foo" (Fail (Error "bar" stack)) => Fail (Error "foobar" stack)
# ```
export def prefixError (prefix: String): (result: Result a Error) => Result a Error = match _
Pass r -> Pass r
Fail (Error msg stack) -> Fail (Error "{prefix}{msg}" stack)

0 comments on commit 182f985

Please sign in to comment.