mirror of
https://github.com/caddyserver/caddy.git
synced 2024-12-01 21:24:23 +08:00
Return errors.
This commit is contained in:
parent
e0bc426050
commit
04089c533b
|
@ -16,19 +16,19 @@ type FileInfo struct {
|
||||||
ctx middleware.Context
|
ctx middleware.Context
|
||||||
}
|
}
|
||||||
|
|
||||||
func (f FileInfo) Summarize(wordcount int) string {
|
func (f FileInfo) Summarize(wordcount int) (string, error) {
|
||||||
fp, err := f.ctx.Root.Open(f.Name())
|
fp, err := f.ctx.Root.Open(f.Name())
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return ""
|
return "", err
|
||||||
}
|
}
|
||||||
defer fp.Close()
|
defer fp.Close()
|
||||||
|
|
||||||
buf, err := ioutil.ReadAll(fp)
|
buf, err := ioutil.ReadAll(fp)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return ""
|
return "", err
|
||||||
}
|
}
|
||||||
|
|
||||||
return string(summary.Markdown(buf, wordcount))
|
return string(summary.Markdown(buf, wordcount)), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// Markdown processes the contents of a page in b. It parses the metadata
|
// Markdown processes the contents of a page in b. It parses the metadata
|
||||||
|
|
Loading…
Reference in New Issue
Block a user