Commits

Josh Rickmar  committed 1e94bd3

Better error handling and formatting.

  • Participants
  • Parent commits 11c52de

Comments (0)

Files changed (1)

 	}
 
 	var writer *bufio.Writer
-	var destPath string
 	if destPath, dest := getDest(srcPath); dest != nil {
-		writer = bufio.NewWriter(dest);
+		writer = bufio.NewWriter(dest)
 
 		// writer flushes before dest closes
 		defer dest.Close()
 		defer func() {
 			if writer != nil && err == nil {
 				err = writer.Flush()
+				if err != nil {
+					panic(err)
+				}
 			}
 		}()
-	} else {	// dest will be null if we're iterating over a directory
+	} else { // dest will be null if we're iterating over a directory
 		if err = os.Mkdir(destPath, 0755); err != nil {
 			panic(err)
 		}
 		mdParser.Markdown(src, markdown.ToHTML(buf))
 		pageElems.Main = template.HTML(buf.String())
 		if err = tmplParser.Execute(writer, pageElems); err != nil {
-			return fmt.Errorf("Could not parse template for file %s\n", destPath);
+			panic(err)
 		}
 	default:
 		io.Copy(writer, src)