added new function, FormatFatal
This commit is contained in:
parent
d00b90b00b
commit
0a512f8d47
9
main.go
9
main.go
@ -1,8 +1,15 @@
|
|||||||
package errorhandler
|
package errorhandler
|
||||||
|
|
||||||
import "fmt"
|
import (
|
||||||
|
"fmt"
|
||||||
|
"log"
|
||||||
|
)
|
||||||
|
|
||||||
// FormatError formats text and the error in a standardized way
|
// FormatError formats text and the error in a standardized way
|
||||||
func FormatError(text string, err error) error {
|
func FormatError(text string, err error) error {
|
||||||
return fmt.Errorf(fmt.Sprintf("%s, error is:\n\t-> %s", text, err))
|
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))
|
||||||
|
}
|
||||||
|
@ -6,7 +6,7 @@ import (
|
|||||||
"testing"
|
"testing"
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestCheck(t *testing.T) {
|
func TestFormatError(t *testing.T) {
|
||||||
text := "text before error"
|
text := "text before error"
|
||||||
err := "test error"
|
err := "test error"
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user