This repository has been archived on 2024-06-24. You can view files and clone it, but cannot push or open issues or pull requests.
huia/packages/core/result/error.huia
James Harton 96677aa499 Start writing some ideas for how things might work in Huia.
I know this is dumb, but it's the best way for be to crystalise my thoughts about how this will work.
2018-08-29 12:46:07 +12:00

20 lines
436 B
Text

deftype Result.Error, error: Error, as: ->
defstatic <Result.Error> new error: Error, as: ->
Result.Error{ error: error }
end
end
defimpl Result, for: Result.Error, as: ->
def ok? as: -> false
def error? as: -> true
def <Any> unwrap as: ->
Huia.Primitive.panic_process(@error)
end
def <Any> expect message: String, as: ->
Huia.Primitive.panic_process(Error.new(message: message, cause: @error))
end
end