Skip to content

Commit

Permalink
fix: error message wrapping (#139)
Browse files Browse the repository at this point in the history
closes #131

Signed-off-by: Carlos A Becker <caarlos0@users.noreply.github.com>

Signed-off-by: Carlos A Becker <caarlos0@users.noreply.github.com>
  • Loading branch information
caarlos0 authored Jan 5, 2023
1 parent d883579 commit 49769a7
Showing 1 changed file with 14 additions and 3 deletions.
17 changes: 14 additions & 3 deletions wishlist.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ type ListModel struct {
endpoints []*Endpoint
client SSHClient
quitting bool
width int
err error
}

Expand Down Expand Up @@ -148,6 +149,7 @@ func (m *ListModel) Update(msg tea.Msg) (tea.Model, tea.Cmd) {

case tea.WindowSizeMsg:
top, right, bottom, left := docStyle.GetMargin()
m.width = msg.Width
m.list.SetSize(msg.Width-left-right, msg.Height-top-bottom)

case SetEndpointsMsg:
Expand Down Expand Up @@ -188,10 +190,19 @@ func (m *ListModel) View() string {
}

if m.err != nil {
header := lipgloss.NewStyle().
Width(m.width).
Render("Something went wrong:")
errstr := errStyle.Copy().
Width(m.width).
Render(rootCause(m.err).Error())
footer := footerStyle.Copy().
Width(m.width).
Render("Press any key to go back to the list.")
return logoStyle.String() + "\n\n" +
"Something went wrong:" + "\n\n" +
errStyle.Render(rootCause(m.err).Error()) + "\n\n" +
footerStyle.Render("Press any key to go back to the list.") + "\n"
header + "\n\n" +
errstr + "\n\n" +
footer + "\n"
}
return docStyle.Render(m.list.View())
}
Expand Down

0 comments on commit 49769a7

Please sign in to comment.