From 0f2c5da7df519d240a6c0b2f569d0f2266e5322b Mon Sep 17 00:00:00 2001 From: "Gerasimos (Makis) Maropoulos" Date: Wed, 3 Oct 2018 20:49:49 +0300 Subject: [PATCH] context#ErrEmptyForm Former-commit-id: c623e7ac433f11c9d89376bee0cd100aa26f35c5 --- context/context.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/context/context.go b/context/context.go index a213b3b7..e39d29fd 100644 --- a/context/context.go +++ b/context/context.go @@ -2289,6 +2289,9 @@ var ( errReadBody = errors.New("while trying to read %s from the request body. Trace %s") ) +// ErrEmptyForm will be thrown from `context#ReadForm` when empty request data. +var ErrEmptyForm = errors.New("form data: empty") + // ReadForm binds the formObject with the form data // it supports any kind of struct. // @@ -2296,7 +2299,7 @@ var ( func (ctx *context) ReadForm(formObject interface{}) error { values := ctx.FormValues() if values == nil { - return errors.New("An empty form passed on ReadForm") + return ErrEmptyForm } // or dec := formbinder.NewDecoder(&formbinder.DecoderOptions{TagName: "form"})