summaryrefslogtreecommitdiff
path: root/plugins
diff options
context:
space:
mode:
authorValery Piashchynski <[email protected]>2021-06-03 19:43:39 +0300
committerValery Piashchynski <[email protected]>2021-06-03 19:43:39 +0300
commiteb04e1fb4e478ac7d695107d542aa48e36a7c32a (patch)
treef6f7a571c264b9cdace36ae1e0886e3eeda06ffc /plugins
parent3b06949c7e9a1fc5b2aec7529a97320a6f398535 (diff)
parentc3e57fd82d59be19b2c41479e9019c60a0afc28f (diff)
Merge remote-tracking branch 'origin/master' into bug/fcgi_leads_to_npe
Diffstat (limited to 'plugins')
-rw-r--r--plugins/http/config/http.go7
-rw-r--r--plugins/http/plugin.go2
-rw-r--r--plugins/server/plugin.go12
3 files changed, 21 insertions, 0 deletions
diff --git a/plugins/http/config/http.go b/plugins/http/config/http.go
index a1c2afa6..f06adc49 100644
--- a/plugins/http/config/http.go
+++ b/plugins/http/config/http.go
@@ -15,6 +15,9 @@ type HTTP struct {
// Host and port to handle as http server.
Address string
+ // InternalErrorCode used to override default 500 (InternalServerError) http code
+ InternalErrorCode uint64 `mapstructure:"internal_error_code"`
+
// SSLConfig defines https server options.
SSLConfig *SSL `mapstructure:"ssl"`
@@ -80,6 +83,10 @@ func (c *HTTP) InitDefaults() error {
}
}
+ if c.InternalErrorCode == 0 {
+ c.InternalErrorCode = 500
+ }
+
if c.HTTP2Config == nil {
c.HTTP2Config = &HTTP2{}
}
diff --git a/plugins/http/plugin.go b/plugins/http/plugin.go
index 770ca8ca..1952679a 100644
--- a/plugins/http/plugin.go
+++ b/plugins/http/plugin.go
@@ -149,6 +149,7 @@ func (p *Plugin) serve(errCh chan error) {
p.handler, err = handler.NewHandler(
p.cfg.MaxRequestSize,
+ p.cfg.InternalErrorCode,
*p.cfg.Uploads,
p.cfg.Cidrs,
p.pool,
@@ -323,6 +324,7 @@ func (p *Plugin) Reset() error {
p.handler, err = handler.NewHandler(
p.cfg.MaxRequestSize,
+ p.cfg.InternalErrorCode,
*p.cfg.Uploads,
p.cfg.Cidrs,
p.pool,
diff --git a/plugins/server/plugin.go b/plugins/server/plugin.go
index aab9dcde..7f694f3c 100644
--- a/plugins/server/plugin.go
+++ b/plugins/server/plugin.go
@@ -235,6 +235,18 @@ func (server *Plugin) collectEvents(event interface{}) {
if we, ok := event.(events.WorkerEvent); ok {
switch we.Event {
case events.EventWorkerError:
+ switch e := we.Payload.(type) { //nolint:gocritic
+ case error:
+ if errors.Is(errors.SoftJob, e) {
+ // get source error for the softjob error
+ server.log.Error(strings.TrimRight(e.(*errors.Error).Err.Error(), " \n\t"))
+ return
+ }
+
+ // print full error for the other types of errors
+ server.log.Error(strings.TrimRight(e.Error(), " \n\t"))
+ return
+ }
server.log.Error(strings.TrimRight(we.Payload.(error).Error(), " \n\t"))
case events.EventWorkerLog:
server.log.Debug(strings.TrimRight(utils.AsString(we.Payload.([]byte)), " \n\t"))