Skip to content

Commit ec2bc31

Browse files
committed
feat: show error if download fails
1 parent 181715f commit ec2bc31

File tree

2 files changed

+19
-4
lines changed

2 files changed

+19
-4
lines changed

pkg/components/build/model.go

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ type DownloadStatus struct {
3636
// One of "success", "failure', or empty if Status not "completed"
3737
Conclusion string
3838
Path string
39+
Error string // Error message if Conclusion is "failure"
3940
}
4041

4142
type TickMsg time.Time
@@ -47,6 +48,7 @@ type DownloadMsg struct {
4748
Status string
4849
// One of "success", "failure',
4950
Conclusion string
51+
Error string
5052
}
5153

5254
func NewModel(client stainless.Client, ctx context.Context, build stainless.Build, branch string, downloadPaths map[stainless.Target]string) Model {
@@ -93,8 +95,9 @@ func (m Model) Update(msg tea.Msg) (Model, tea.Cmd) {
9395

9496
case DownloadMsg:
9597
download := m.Downloads[msg.Target]
96-
download.Status = "completed"
98+
download.Status = msg.Status
9799
download.Conclusion = msg.Conclusion
100+
download.Error = msg.Error
98101
m.Downloads[msg.Target] = download
99102

100103
case FetchBuildMsg:
@@ -141,10 +144,18 @@ func (m Model) downloadTarget(target stainless.Target) tea.Cmd {
141144
}
142145
err = PullOutput(outputRes.Output, outputRes.URL, outputRes.Ref, m.Branch, m.Downloads[target].Path, console.NewGroup(true))
143146
if err != nil {
144-
console.Error(fmt.Sprintf("Failed to download %s: %v", target, err))
145-
return DownloadMsg{target, "completed", "failure"}
147+
return DownloadMsg{
148+
Target: target,
149+
Status: "completed",
150+
Conclusion: "failure",
151+
Error: err.Error(),
152+
}
153+
}
154+
return DownloadMsg{
155+
Target: target,
156+
Status: "completed",
157+
Conclusion: "success",
146158
}
147-
return DownloadMsg{target, "completed", "success"}
148159
}
149160
}
150161

pkg/components/build/view.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,10 @@ func ViewBuildPipeline(build stainless.Build, target stainless.Target, downloads
7777

7878
if download, ok := downloads[target]; ok {
7979
pipeline.WriteString(" " + ViewStepSymbol(download.Status, download.Conclusion) + " " + "download")
80+
if download.Conclusion == "failure" && download.Error != "" {
81+
errorStyle := lipgloss.NewStyle().Foreground(lipgloss.Color("1"))
82+
pipeline.WriteString("\n" + errorStyle.Render(" Error: "+download.Error))
83+
}
8084
}
8185

8286
return pipeline.String()

0 commit comments

Comments
 (0)