diff options
author | Alan Pearce | 2024-04-28 19:49:40 +0200 |
---|---|---|
committer | Alan Pearce | 2024-04-28 19:49:40 +0200 |
commit | 44a3b3bbd1b8b7c11eed7cce9a07aa4c07cdb90e (patch) | |
tree | 6650f8503e1328b067050f7a3ea131e08885d9d9 /internal/builder/builder.go | |
parent | 88d56a2420f75ae202fda76b19c3d95c001df546 (diff) | |
download | website-44a3b3bbd1b8b7c11eed7cce9a07aa4c07cdb90e.tar.lz website-44a3b3bbd1b8b7c11eed7cce9a07aa4c07cdb90e.tar.zst website-44a3b3bbd1b8b7c11eed7cce9a07aa4c07cdb90e.zip |
builder: return errors instead of panicking
Diffstat (limited to 'internal/builder/builder.go')
-rw-r--r-- | internal/builder/builder.go | 7 |
1 files changed, 3 insertions, 4 deletions
diff --git a/internal/builder/builder.go b/internal/builder/builder.go index 88e3f02..90e957c 100644 --- a/internal/builder/builder.go +++ b/internal/builder/builder.go @@ -3,7 +3,6 @@ package builder import ( "fmt" "io" - "log" "log/slog" "net/url" "os" @@ -175,21 +174,21 @@ func build(outDir string, config config.Config) error { func BuildSite(ioConfig IOConfig) error { config, err := config.GetConfig() if err != nil { - log.Panic(errors.Errorf("could not get config: %v", err)) + return errors.WithMessage(err, "could not get config") } config.InjectLiveReload = ioConfig.Development if ioConfig.BaseURL.URL != nil { config.BaseURL.URL, err = url.Parse(ioConfig.BaseURL.String()) if err != nil { - log.Panic(errors.Errorf("highly unlikely: %v", err)) + return errors.WithMessage(err, "could not re-parse base URL") } } if ioConfig.Development && ioConfig.Destination != "website" { err = os.RemoveAll(ioConfig.Destination) if err != nil { - log.Panic(errors.Errorf("could not remove destination directory: %v", err)) + return errors.WithMessage(err, "could not remove destination directory") } } |