Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
18 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
129 changes: 0 additions & 129 deletions circuit/circuits.go

This file was deleted.

58 changes: 58 additions & 0 deletions error/error.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
package error

import (
"fmt"
"strings"
)

type ChakiError struct {
ClientName string
StatusCode int
RawBody []byte
ParsedBody interface{}
}

func (e *ChakiError) Error() string {
msg := fmt.Sprintf("Error on client %s (Status %d)", e.ClientName, e.StatusCode)
if details := e.extractErrorDetails(); details != "" {
msg += ": " + details
}

return msg
}

func (e *ChakiError) Status() int {
return e.StatusCode
}

type RandomError interface {
Status() int
}

func (e *ChakiError) extractErrorDetails() string {
var details []string

var extract func(interface{})
extract = func(v interface{}) {
switch value := v.(type) {
case string:
details = append(details, strings.TrimSpace(value))
case map[string]interface{}:
for _, v := range value {
extract(v)
}
case []interface{}:
for _, v := range value {
extract(v)
}
}
}

extract(e.ParsedBody)

if len(details) == 0 && len(e.RawBody) > 0 {
return strings.TrimSpace(string(e.RawBody))
}

return strings.Join(details, "; ")
}
76 changes: 0 additions & 76 deletions example/client-server-with-otel/client/client.go

This file was deleted.

80 changes: 0 additions & 80 deletions example/client-server-with-otel/client/main.go

This file was deleted.

16 changes: 0 additions & 16 deletions example/client-server-with-otel/client/request.go

This file was deleted.

This file was deleted.

Loading
Loading