commands: Improve error messages in convert
authorBjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>
Tue, 13 Sep 2016 17:11:36 +0000 (19:11 +0200)
committerBjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>
Tue, 13 Sep 2016 17:11:59 +0000 (19:11 +0200)
See #2440

commands/convert.go

index b9aa7b8fa32f2884630f0266800e6904ed296d22..da82178101595bb4fca289a55445f482bd1c3838 100644 (file)
@@ -137,17 +137,17 @@ func convertContents(mark rune) (err error) {
                page.SetDir(filepath.Join(helpers.AbsPathify(viper.GetString("ContentDir")), file.Dir()))
                page.SetSourceContent(psr.Content())
                if err = page.SetSourceMetaData(metadata, mark); err != nil {
-                       return err
+                       return fmt.Errorf("Failed to set source metadata for file %q: %s", page.FullFilePath(), err)
                }
 
                if outputDir != "" {
                        if err = page.SaveSourceAs(filepath.Join(outputDir, page.FullFilePath())); err != nil {
-                               return err
+                               return fmt.Errorf("Failed to save file %q: %s", page.FullFilePath(), err)
                        }
                } else {
                        if unsafe {
                                if err = page.SaveSource(); err != nil {
-                                       return err
+                                       return fmt.Errorf("Failed to save file %q: %s", page.FullFilePath(), err)
                                }
                        } else {
                                jww.FEEDBACK.Println("Unsafe operation not allowed, use --unsafe or set a different output path")