diff --git a/main.go b/main.go index 6f1854b..eebdfe7 100644 --- a/main.go +++ b/main.go @@ -1,8 +1,15 @@ package errorhandler -import "fmt" +import ( + "fmt" + "log" +) // FormatError formats text and the error in a standardized way func FormatError(text string, err error) error { return fmt.Errorf(fmt.Sprintf("%s, error is:\n\t-> %s", text, err)) } + +func FormatFatal(text string, err error) { + log.Fatalf(fmt.Sprintf("%s, error is:\n\t-> %s", text, err)) +} diff --git a/main_test.go b/main_test.go index 8ad65df..b61f55e 100644 --- a/main_test.go +++ b/main_test.go @@ -6,7 +6,7 @@ import ( "testing" ) -func TestCheck(t *testing.T) { +func TestFormatError(t *testing.T) { text := "text before error" err := "test error"