mirror of
https://github.com/yusing/godoxy.git
synced 2026-04-28 03:07:07 +02:00
feat: enhanced error handling module
This commit is contained in:
@@ -1,11 +1,12 @@
|
||||
package gperr
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"slices"
|
||||
"strings"
|
||||
|
||||
"github.com/yusing/go-proxy/pkg/json"
|
||||
|
||||
"github.com/yusing/go-proxy/internal/utils/strutils/ansi"
|
||||
)
|
||||
|
||||
@@ -93,8 +94,7 @@ func (err *withSubject) Error() string {
|
||||
return sb.String()
|
||||
}
|
||||
|
||||
// MarshalJSON implements the json.Marshaler interface.
|
||||
func (err *withSubject) MarshalJSON() ([]byte, error) {
|
||||
func (err *withSubject) MarshalJSONTo(buf []byte) []byte {
|
||||
subjects := slices.Clone(err.Subjects)
|
||||
slices.Reverse(subjects)
|
||||
|
||||
@@ -102,5 +102,5 @@ func (err *withSubject) MarshalJSON() ([]byte, error) {
|
||||
"subjects": subjects,
|
||||
"err": err.Err,
|
||||
}
|
||||
return json.Marshal(reversed)
|
||||
return json.MarshalTo(reversed, buf)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user