From 0616ba42d65edb9e47b29bd5e7ff068f6155c33a Mon Sep 17 00:00:00 2001 From: Elliott Stoneham Date: Fri, 6 May 2016 14:26:29 +0100 Subject: [PATCH] report when smart-sections are not found --- documize/api/endpoint/page_endpoint.go | 11 +++++++++-- documize/api/endpoint/sections_endpoint.go | 15 ++++++++++++--- documize/section/section.go | 2 +- 3 files changed, 22 insertions(+), 6 deletions(-) diff --git a/documize/api/endpoint/page_endpoint.go b/documize/api/endpoint/page_endpoint.go index 7b52115f..cd7972a2 100644 --- a/documize/api/endpoint/page_endpoint.go +++ b/documize/api/endpoint/page_endpoint.go @@ -79,7 +79,11 @@ func AddDocumentPage(w http.ResponseWriter, r *http.Request) { p.Context.Transaction = tx - output, _ := section.Render(model.Page.ContentType, model.Meta.Config, model.Meta.RawBody) + output, ok := section.Render(model.Page.ContentType, model.Meta.Config, model.Meta.RawBody) + if !ok { + log.ErrorString("section.Render could not find: " + model.Page.ContentType) + } + model.Page.Body = output err = p.AddPage(*model) @@ -418,7 +422,10 @@ func UpdateDocumentPage(w http.ResponseWriter, r *http.Request) { model.Page.SetDefaults() model.Meta.SetDefaults() - output, _ := section.Render(model.Page.ContentType, model.Meta.Config, model.Meta.RawBody) + output, ok := section.Render(model.Page.ContentType, model.Meta.Config, model.Meta.RawBody) + if !ok { + log.ErrorString("section.Render could not find: " + model.Page.ContentType) + } model.Page.Body = output p.Context.Transaction = tx diff --git a/documize/api/endpoint/sections_endpoint.go b/documize/api/endpoint/sections_endpoint.go index 9ba46a17..d1670184 100644 --- a/documize/api/endpoint/sections_endpoint.go +++ b/documize/api/endpoint/sections_endpoint.go @@ -59,7 +59,10 @@ func RunSectionCommand(w http.ResponseWriter, r *http.Request) { return } - section.Command(sectionName, w, r) + if !section.Command(sectionName, w, r) { + log.ErrorString("Unable to run section.Command() for: " + sectionName) + writeNotFoundError(w, "RunSectionCommand", sectionName) + } } // RefreshSections updates document sections where the data @@ -112,10 +115,16 @@ func RefreshSections(w http.ResponseWriter, r *http.Request) { } // Ask for data refresh - data, _ := section.Refresh(page.ContentType, pm.Config, pm.RawBody) + data, ok := section.Refresh(page.ContentType, pm.Config, pm.RawBody) + if !ok { + log.ErrorString("section.Refresh could not find: " + page.ContentType) + } // Render again - body, _ := section.Render(page.ContentType, pm.Config, data) + body, ok := section.Render(page.ContentType, pm.Config, data) + if !ok { + log.ErrorString("section.Render could not find: " + page.ContentType) + } // Compare to stored render if body != page.Body { diff --git a/documize/section/section.go b/documize/section/section.go index b73c5983..26522e9c 100644 --- a/documize/section/section.go +++ b/documize/section/section.go @@ -48,7 +48,7 @@ func Command(section string, w http.ResponseWriter, r *http.Request) bool { if ok { s.Command(w, r) } - return false + return ok } // Render runs that operation for the given section id, the returned bool indicates success.