diff --git a/cmd/cory-bin/main.go b/cmd/cory-bin/main.go index db8d99d..57e5077 100644 --- a/cmd/cory-bin/main.go +++ b/cmd/cory-bin/main.go @@ -48,7 +48,11 @@ func main() { printIf("could not find file %s\n", filename) return } - dump(filename, output) + err := dump(filename, output) + if err != nil { + fmt.Println(err) + return + } return } flag.PrintDefaults() @@ -60,25 +64,26 @@ func printIf(s string, args ...interface{}) { } } -func dump(filename string, output string) { +func dump(filename string, output string) error { start := time.Now() printIf("reading file '%s'\n", filename) n, err := nori.FromFile(filename) if err != nil { - log.Panicf("decode: %s", err) + return fmt.Errorf("decode: %w", err) } out := new(bytes.Buffer) printIf("rendering %d animation(s)\n", n.AnimationCount) animations, err := renderer.RenderAnimationsApng(n) if err != nil { - log.Panicf("animation: %s\n", err) + return fmt.Errorf("animation: %w", err) } printIf("saving to %s \n", output) if err := utils.ZipApngs(out, animations); err != nil { - log.Panicf("zipping: %s\n", err) + return fmt.Errorf("zipping: %w", err) } printIf("done in %v \n", time.Now().Sub(start)) os.WriteFile(output, out.Bytes(), 0740) + return nil } func serve() { @@ -92,7 +97,7 @@ func serve() { r.Use(middleware.Timeout(60 * time.Second)) r.Post("/animations", func(w http.ResponseWriter, r *http.Request) { - output_type := chi.URLParam(r, "format") + output_type := r.URL.Query().Get("format") switch output_type { case "": output_type = "apng"