diff options
| author | William Boman <william@redwill.se> | 2022-10-30 17:43:46 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-10-30 17:43:46 +0100 |
| commit | 37c745fa73b983c86904132efb30ef2a4a76df5e (patch) | |
| tree | c55fe52b7c5c20ed4fdbb3ee073519fd0ccbe6b2 /lua/mason-core/optional.lua | |
| parent | chore: update generated code (#608) (diff) | |
| download | mason-37c745fa73b983c86904132efb30ef2a4a76df5e.tar mason-37c745fa73b983c86904132efb30ef2a4a76df5e.tar.gz mason-37c745fa73b983c86904132efb30ef2a4a76df5e.tar.bz2 mason-37c745fa73b983c86904132efb30ef2a4a76df5e.tar.lz mason-37c745fa73b983c86904132efb30ef2a4a76df5e.tar.xz mason-37c745fa73b983c86904132efb30ef2a4a76df5e.tar.zst mason-37c745fa73b983c86904132efb30ef2a4a76df5e.zip | |
feat: add provider interface (#601)
Diffstat (limited to 'lua/mason-core/optional.lua')
| -rw-r--r-- | lua/mason-core/optional.lua | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/lua/mason-core/optional.lua b/lua/mason-core/optional.lua index 6eb0719e..cc40da77 100644 --- a/lua/mason-core/optional.lua +++ b/lua/mason-core/optional.lua @@ -105,13 +105,17 @@ function Optional:is_present() return self._value ~= nil end ----@param err fun(): any +---@param err (fun(): any)|string function Optional:ok_or(err) local Result = require "mason-core.result" if self:is_present() then return Result.success(self:get()) else - return Result.failure(err()) + if type(err) == "string" then + return Result.failure(err) + else + return Result.failure(err()) + end end end |
