make errors more explicit #25
parent
c7798814ea
commit
4ea19cab92
|
@ -3,6 +3,7 @@ package editor
|
||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
|
"errors"
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"net/http"
|
"net/http"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
|
@ -52,7 +53,7 @@ func POST(w http.ResponseWriter, r *http.Request, c *config.Config, filename str
|
||||||
|
|
||||||
file = f
|
file = f
|
||||||
default:
|
default:
|
||||||
return http.StatusBadRequest, nil
|
return http.StatusBadRequest, errors.New("X-Content-Type header not defined")
|
||||||
}
|
}
|
||||||
|
|
||||||
// Write the file
|
// Write the file
|
||||||
|
@ -80,7 +81,7 @@ func parseFrontMatterOnlyFile(rawFile map[string]interface{}, filename string) (
|
||||||
case "yaml":
|
case "yaml":
|
||||||
mark = rune('-')
|
mark = rune('-')
|
||||||
default:
|
default:
|
||||||
return []byte{}, http.StatusNotFound, nil
|
return []byte{}, http.StatusBadRequest, errors.New("can't define the frontmatter")
|
||||||
}
|
}
|
||||||
|
|
||||||
f, err := parser.InterfaceToFrontMatter(rawFile, mark)
|
f, err := parser.InterfaceToFrontMatter(rawFile, mark)
|
||||||
|
|
Loading…
Reference in New Issue