<commit_before>package emperror_test

import (
	"testing"

	"errors"

	"github.com/goph/emperror"
	"github.com/stretchr/testify/assert"
)

func TestHandleRecovery(t *testing.T) {
	handler := new(emperror.TestHandler)
	err := errors.New("error")

	defer func() {
		assert.EqualError(t, handler.Last(), "error")
	}()
	defer emperror.HandleRecover(handler)

	panic(err)
}

func TestHandleIfErr(t *testing.T) {
	handler := new(emperror.TestHandler)
	err := errors.New("error")

	emperror.HandleIfErr(handler, err)
<commit_msg>Add test for Panic<commit_after>package emperror_test

import (
	"testing"

	"errors"

	"github.com/goph/emperror"
	"github.com/stretchr/testify/assert"
)

func TestHandleRecovery(t *testing.T) {
	handler := new(emperror.TestHandler)
	err := errors.New("error")

	defer func() {
		assert.EqualError(t, handler.Last(), "error")
	}()
	defer emperror.HandleRecover(handler)

	panic(err)
}

func TestPanic(t *testing.T) {
	assert.Panics(t, func() {
		emperror.Panic(errors.New("error"))
	})
}

func TestPanic_NoError(t *testing.T) {
	assert.NotPanics(t, func() {
		emperror.Panic(nil)
	})
}

func TestHandleIfErr(t *testing.T) {
	handler := new(emperror.TestHandler)
	err := errors.New("error")

	emperror.HandleIfErr(handler, err)

{'fraction_non_alphanumeric': 0.1592, 'fraction_numerical': 0.0, 'mean_word_length': 5.102439024390244, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4903973', 'n_tokens_mistral': 495, 'n_tokens_neox': 492, 'n_words': 77}