Skip to content
This repository has been archived by the owner on Dec 1, 2021. It is now read-only.

Add Errorf #14

Merged
merged 1 commit into from
Apr 29, 2016
Merged

Add Errorf #14

merged 1 commit into from
Apr 29, 2016

Conversation

scorredoira
Copy link
Contributor

@scorredoira scorredoira commented Apr 26, 2016

Fixes #13

@davecheney
Copy link
Member

Thank you. Before I can merge this, please add tests and examples.

@@ -130,6 +130,18 @@ func (c cause) Error() string { return c.Message() + ": " + c.Cause().Error()
func (c cause) Cause() error { return c.cause }
func (c cause) Message() string { return c.message }

// Errorf returns an error that formats as the given text.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Errorf formats according to a format specifier and returns the string as a value that satisfies error.

@paulstuart
Copy link

I know this is late to the dance, but why not have optional arguments to New and treat it as printf?

@davecheney
Copy link
Member

@paulstuart probably for the same reason as #6 (comment)

Please open a new issue to discuss this, I'm about to merge this PR and this discussion may be lost.

@davecheney davecheney merged commit 7a0abd8 into pkg:master Apr 29, 2016
@paulstuart
Copy link

@davecheney the existing solution is fine. It just seemed like the idea was a clean and minimal enhancement. My itch is scratched. Keep doing the good you do.

@davecheney
Copy link
Member

Hmm, so New() could be redefined as New(string, ...string) but I'm not sure how useful that would be, if you want more complicated formatting, Errorf would probably be the right tool for the job.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants