Skip to content

Commit

Permalink
refactor: use error so user can get a stack trace
Browse files Browse the repository at this point in the history
  • Loading branch information
pogyomo committed Jun 14, 2024
1 parent 18a68a5 commit 19d4320
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 12 deletions.
10 changes: 2 additions & 8 deletions lua/submode/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,7 @@ function M.create(name, info, register)
-- Judge to continue process by checking `override_behavior`.
if state.submode_to_info[name] then
if state.submode_to_info[name].override_behavior == "error" then
vim.notify(string.format("submode `%s` already exists", name), vim.log.levels.ERROR, {
title = "submode.nvim",
})
return
error(string.format("submode `%s` already exists", name))
elseif state.submode_to_info[name].override_behavior == "keep" then
return
end
Expand Down Expand Up @@ -174,10 +171,7 @@ function M.enter(name)

-- Validate given submode's name.
if not info then
vim.notify(string.format("submode `%s` doesn't exist", name), vim.log.levels.ERROR, {
title = "submode.nvim",
})
return
error(string.format("submode `%s` doesn't exist", name))
end

-- Validate that current mode and submode's parent mode is same
Expand Down
5 changes: 1 addition & 4 deletions lua/submode/mode.lua
Original file line number Diff line number Diff line change
Expand Up @@ -90,10 +90,7 @@ function M.is_parent_same(submode, name)
["!"] = fany { M.is_insert_mode, M.is_cmdline_mode },
[""] = fany { M.is_normal_mode, M.is_visual_mode, M.is_o_pending_mode },
}, function()
vim.notify(string.format("invalid mode `%s`", parent), vim.log.levels.ERROR, {
title = "submode.nvim",
})
return false
error(string.format("invalid mode `%s`", parent))
end)
end

Expand Down

0 comments on commit 19d4320

Please sign in to comment.