Skip to content

Commit

Permalink
fix: show errors message on fails for routes and commands
Browse files Browse the repository at this point in the history
  • Loading branch information
adalessa committed Dec 29, 2023
1 parent 2fe1157 commit 36c67ca
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 6 deletions.
4 changes: 2 additions & 2 deletions lua/laravel/api/response.lua
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ end

---@return string
function ApiResponse:prettyContent()
return table.concat(self:content(), "\r\n")
return table.concat(self:content(), "\n")
end

---@return string|nil
Expand Down Expand Up @@ -71,7 +71,7 @@ function ApiResponse:prettyErrors()
return ""
end

return table.concat(errors, "\r\n")
return table.concat(errors, "\n")
end

return ApiResponse
3 changes: 2 additions & 1 deletion lua/laravel/commands/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ function M.load()
M.list = {}
local result = api.sync("artisan", { "list", "--format=json" })
if result:failed() then
error(result:failed(), vim.log.levels.ERROR)
vim.notify(result:prettyErrors(), vim.log.levels.ERROR)
return false
end

M.list = utils.from_json(result.stdout)
Expand Down
3 changes: 2 additions & 1 deletion lua/laravel/routes/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ function M.load()
M.list = {}
local result = api.sync("artisan", { "route:list", "--json" })
if result:failed() then
error(result:errors(), vim.log.levels.ERROR)
vim.notify(result:prettyErrors(), vim.log.levels.ERROR)
return false
end

M.list = utils.from_json(result.stdout)
Expand Down
6 changes: 4 additions & 2 deletions lua/laravel/telescope/pickers/commands.lua
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,10 @@ local actions = require "laravel.telescope.actions"
return function(opts)
opts = opts or {}

if #commands.list == 0 then
commands.load()
if vim.tbl_isempty(commands.list) then
if not commands.load() then
return
end
end

pickers
Expand Down

0 comments on commit 36c67ca

Please sign in to comment.