Skip to content

Commit

Permalink
config: fix issue where sst crashes on certain invalid config build
Browse files Browse the repository at this point in the history
errors
  • Loading branch information
thdxr committed Jul 5, 2024
1 parent f6ef244 commit 92f90da
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions pkg/js/js.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,12 +59,7 @@ const __dirname = topLevelFileUrlToPath(new topLevelURL(".", import.meta.url))
})
if len(result.Errors) > 0 {
for _, err := range result.Errors {
slog.Error("esbuild error",
"text", err.Text,
"location.file", err.Location.File,
"location.line", err.Location.Line,
"column", err.Location.Column,
)
slog.Error("esbuild error", "text", err.Text)
}
return result, fmt.Errorf("%s", FormatError(result.Errors))
}
Expand All @@ -76,6 +71,10 @@ const __dirname = topLevelFileUrlToPath(new topLevelURL(".", import.meta.url))
func FormatError(input []esbuild.Message) string {
lines := []string{}
for _, err := range input {
if err.Location == nil {
lines = append(lines, fmt.Sprintf("%v", err.Text))
continue
}
lines = append(lines, fmt.Sprintf("%v:%v:%v: %v", err.Location.File, err.Location.Line, err.Location.Column, err.Text))
}
return strings.Join(lines, "\n")
Expand Down

0 comments on commit 92f90da

Please sign in to comment.