mirror of
https://github.com/yusing/godoxy.git
synced 2026-03-21 08:39:03 +01:00
v0.5: (BREAKING) new syntax for set_headers and hide_headers, updated label parser, error.Nil().String() will now return 'nil', better readme
This commit is contained in:
@@ -139,9 +139,12 @@ func (ne *NestedError) writeToSB(sb *strings.Builder, level int, prefix string)
|
||||
ne.writeIndents(sb, level)
|
||||
sb.WriteString(prefix)
|
||||
|
||||
if ne.err != nil {
|
||||
sb.WriteString(ne.err.Error())
|
||||
if ne.IsNil() {
|
||||
sb.WriteString("nil")
|
||||
return
|
||||
}
|
||||
|
||||
sb.WriteString(ne.err.Error())
|
||||
if ne.subject != "" {
|
||||
if ne.err != nil {
|
||||
sb.WriteString(fmt.Sprintf(" for %q", ne.subject))
|
||||
|
||||
@@ -19,6 +19,16 @@ func TestErrorIs(t *testing.T) {
|
||||
|
||||
AssertEq(t, Invalid("foo", "bar").Is(ErrInvalid), true)
|
||||
AssertEq(t, Invalid("foo", "bar").Is(ErrFailure), false)
|
||||
|
||||
AssertEq(t, Nil().Is(nil), true)
|
||||
AssertEq(t, Nil().Is(ErrInvalid), false)
|
||||
AssertEq(t, Invalid("foo", "bar").Is(nil), false)
|
||||
}
|
||||
|
||||
func TestNil(t *testing.T) {
|
||||
AssertEq(t, Nil().IsNil(), true)
|
||||
AssertEq(t, Nil().IsNotNil(), false)
|
||||
AssertEq(t, Nil().Error(), "nil")
|
||||
}
|
||||
|
||||
func TestErrorSimple(t *testing.T) {
|
||||
|
||||
Reference in New Issue
Block a user