Skip to content

Commit

Permalink
add Newf for formatting fundamental error messages
Browse files Browse the repository at this point in the history
  • Loading branch information
Southclaws committed Oct 31, 2022
1 parent e2bb44e commit 263482b
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions fundamental.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package fault

import "fmt"

// New creates a new basic fault error.
func New(message string) error {
return &fundamental{
Expand All @@ -8,6 +10,14 @@ func New(message string) error {
}
}

// Newf includes formatting specifiers.
func Newf(message string, va ...any) error {
return &fundamental{
msg: fmt.Sprintf(message, va...),
location: getLocation(),
}
}

type fundamental struct {
msg string
location string
Expand Down

0 comments on commit 263482b

Please sign in to comment.