Skip to content

Commit

Permalink
Add Arguments and KwArguments in Error string (#63)
Browse files Browse the repository at this point in the history
  • Loading branch information
muzzammilshahid authored Nov 13, 2024
1 parent c5b8548 commit e43d826
Showing 1 changed file with 20 additions and 1 deletion.
21 changes: 20 additions & 1 deletion types.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,10 @@ package xconn

import (
"context"
"fmt"
"io"
"net"
"strings"
"time"

"github.com/xconnio/wampproto-go/messages"
Expand Down Expand Up @@ -147,7 +149,24 @@ type Error struct {
}

func (e *Error) Error() string {
return e.URI
errStr := e.URI
if e.Arguments != nil {
args := make([]string, len(e.Arguments))
for i, arg := range e.Arguments {
args[i] = fmt.Sprintf("%v", arg)
}
errStr += ": " + strings.Join(args, ", ")
}

if e.KwArguments != nil {
kwargs := make([]string, len(e.KwArguments))
for key, value := range e.KwArguments {
kwargs = append(kwargs, fmt.Sprintf("%s=%v", key, value))
}
errStr += ": " + strings.Join(kwargs, ", ")
}

return errStr
}

type RegisterResponse struct {
Expand Down

0 comments on commit e43d826

Please sign in to comment.