Skip to content

Commit cd4bf4e

Browse files
authored
Merge pull request #1212 from alecbz/alec/remove-dead-panic
Remove dead panic in Entry.Panic
2 parents 44d983d + 02fcb16 commit cd4bf4e

File tree

2 files changed

+22
-1
lines changed

2 files changed

+22
-1
lines changed

entry.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -317,7 +317,6 @@ func (entry *Entry) Fatal(args ...interface{}) {
317317

318318
func (entry *Entry) Panic(args ...interface{}) {
319319
entry.Log(PanicLevel, args...)
320-
panic(fmt.Sprint(args...))
321320
}
322321

323322
// Entry Printf family functions

entry_test.go

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,28 @@ func TestEntryPanicf(t *testing.T) {
167167
entry.WithField("err", errBoom).Panicf("kaboom %v", true)
168168
}
169169

170+
func TestEntryPanic(t *testing.T) {
171+
errBoom := fmt.Errorf("boom again")
172+
173+
defer func() {
174+
p := recover()
175+
assert.NotNil(t, p)
176+
177+
switch pVal := p.(type) {
178+
case *Entry:
179+
assert.Equal(t, "kaboom", pVal.Message)
180+
assert.Equal(t, errBoom, pVal.Data["err"])
181+
default:
182+
t.Fatalf("want type *Entry, got %T: %#v", pVal, pVal)
183+
}
184+
}()
185+
186+
logger := New()
187+
logger.Out = &bytes.Buffer{}
188+
entry := NewEntry(logger)
189+
entry.WithField("err", errBoom).Panic("kaboom")
190+
}
191+
170192
const (
171193
badMessage = "this is going to panic"
172194
panicMessage = "this is broken"

0 commit comments

Comments
 (0)