From 9fdf20b3e22d2df5493cb24bdab11533a521f8f5 Mon Sep 17 00:00:00 2001 From: John Guo Date: Thu, 17 Feb 2022 11:51:21 +0800 Subject: [PATCH] add SetError for ghttp.Request --- net/ghttp/ghttp_request.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/net/ghttp/ghttp_request.go b/net/ghttp/ghttp_request.go index 2d0d91fdb..da33d83d7 100644 --- a/net/ghttp/ghttp_request.go +++ b/net/ghttp/ghttp_request.go @@ -250,6 +250,11 @@ func (r *Request) GetError() error { return r.error } +// SetError sets custom error for current request. +func (r *Request) SetError(err error) { + r.error = err +} + // ReloadParam is used for modifying request parameter. // Sometimes, we want to modify request parameters through middleware, but directly modifying Request.Body // is invalid, so it clears the parsed* marks to make the parameters re-parsed.