Skip to content

Commit 36c67ca

Browse files
committed
fix: show errors message on fails for routes and commands
1 parent 2fe1157 commit 36c67ca

File tree

4 files changed

+10
-6
lines changed

4 files changed

+10
-6
lines changed

lua/laravel/api/response.lua

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ end
4040

4141
---@return string
4242
function ApiResponse:prettyContent()
43-
return table.concat(self:content(), "\r\n")
43+
return table.concat(self:content(), "\n")
4444
end
4545

4646
---@return string|nil
@@ -71,7 +71,7 @@ function ApiResponse:prettyErrors()
7171
return ""
7272
end
7373

74-
return table.concat(errors, "\r\n")
74+
return table.concat(errors, "\n")
7575
end
7676

7777
return ApiResponse

lua/laravel/commands/init.lua

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,8 @@ function M.load()
99
M.list = {}
1010
local result = api.sync("artisan", { "list", "--format=json" })
1111
if result:failed() then
12-
error(result:failed(), vim.log.levels.ERROR)
12+
vim.notify(result:prettyErrors(), vim.log.levels.ERROR)
13+
return false
1314
end
1415

1516
M.list = utils.from_json(result.stdout)

lua/laravel/routes/init.lua

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,8 @@ function M.load()
99
M.list = {}
1010
local result = api.sync("artisan", { "route:list", "--json" })
1111
if result:failed() then
12-
error(result:errors(), vim.log.levels.ERROR)
12+
vim.notify(result:prettyErrors(), vim.log.levels.ERROR)
13+
return false
1314
end
1415

1516
M.list = utils.from_json(result.stdout)

lua/laravel/telescope/pickers/commands.lua

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,10 @@ local actions = require "laravel.telescope.actions"
99
return function(opts)
1010
opts = opts or {}
1111

12-
if #commands.list == 0 then
13-
commands.load()
12+
if vim.tbl_isempty(commands.list) then
13+
if not commands.load() then
14+
return
15+
end
1416
end
1517

1618
pickers

0 commit comments

Comments
 (0)