From 69e5bcefe5ce66b3273cdfb0389101b47bd44447 Mon Sep 17 00:00:00 2001 From: some Date: Thu, 10 Oct 2024 15:04:22 -0400 Subject: [PATCH] Add SetErrorHandler method to DefaultResponseBuilder --- default.go | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/default.go b/default.go index 7d71155..f821304 100644 --- a/default.go +++ b/default.go @@ -236,6 +236,11 @@ func NewDefaultResponseBuilder() *DefaultResponseBuilder { return &DefaultResponseBuilder{} } +func (rsb *DefaultResponseBuilder) SetErrorHandler(errorHandler Error) *DefaultResponseBuilder { + rsb.errorHandler = errorHandler + return rsb +} + func (rsb *DefaultResponseBuilder) SetStatus(code *int) *DefaultResponseBuilder { rsb.status = code return rsb @@ -254,6 +259,9 @@ func (rsb *DefaultResponseBuilder) SetBody(parsed *Body, fields body) *DefaultRe } func (rsb *DefaultResponseBuilder) SetDefaults() *DefaultResponseBuilder { + if rsb.errorHandler == nil { + rsb.errorHandler = &DefaultErrorHandler{} + } if rsb.status == nil { c := http.StatusOK rsb.status = &c