Skip to content

Commit

Permalink
feat: add func to render errors
Browse files Browse the repository at this point in the history
  • Loading branch information
s1ntaxe770r authored and andrew-s committed May 26, 2024
1 parent e1851f7 commit 5a345ff
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions charm/errors.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package charm

import (
"errors"
"fmt"
)

func RenderError(message string, err ...error) error {
formattedMessage := ErrorStyle.Render(message)
if len(err) > 0 && err[0] != nil {
return fmt.Errorf("%s: %w", formattedMessage, err[0])
}
return errors.New(formattedMessage)
}

0 comments on commit 5a345ff

Please sign in to comment.