Skip to content

Commit

Permalink
ServiceError fix
Browse files Browse the repository at this point in the history
  • Loading branch information
pieceowater committed Oct 1, 2024
1 parent 8a37257 commit 933ad2a
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 7 deletions.
4 changes: 2 additions & 2 deletions gossiper.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,8 @@ func LogAction(action string, data any) {
}

// NewServiceError creates a new internal.ServiceError instance.
func NewServiceError(message string) *internal.ServiceError {
return internal.NewServiceError(message)
func NewServiceError(message string, statusCode ...int) *internal.ServiceError {
return internal.NewServiceError(message, statusCode...)
}

// Enum with aliases for predefined pagination page length.
Expand Down
4 changes: 2 additions & 2 deletions internal/index.go
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,6 @@ const (
type ServiceError = errors.ServiceError

// NewServiceError creates a new instance of errors.ServiceError with the provided message.
func NewServiceError(message string) *errors.ServiceError {
return errors.NewServiceError(message)
func NewServiceError(message string, statusCode ...int) *ServiceError {
return errors.NewServiceError(message, statusCode...)
}
2 changes: 1 addition & 1 deletion internal/tools/formats/errors/error.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ func (e *ServiceError) Error() string {
}

// GetError returns a map representing the error status code and message.
func (e *ServiceError) GetError() map[string]interface{} {
func (e *ServiceError) GetError() map[string]any {
return map[string]any{
"message": e.Message,
"statusCode": e.StatusCode,
Expand Down
4 changes: 2 additions & 2 deletions internal/tools/satisfies.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ func (inst *Tools) setDefaultsAndConvert(dest any) {

// convertFields converts string values in the provided data map to the appropriate types
// in the destination struct. It supports converting basic types and pointer types.
func (inst *Tools) convertFields(data map[string]interface{}, dest any) error {
func (inst *Tools) convertFields(data map[string]any, dest any) error {
v := reflect.ValueOf(dest).Elem()

for key, value := range data {
Expand Down Expand Up @@ -198,7 +198,7 @@ func (inst *Tools) Satisfies(data any, dest any) error {
return err
}

if dataMap, ok := data.(map[string]interface{}); ok {
if dataMap, ok := data.(map[string]any); ok {
err = inst.convertFields(dataMap, dest)
if err != nil {
return err
Expand Down

0 comments on commit 933ad2a

Please sign in to comment.