Home / Function/ NewErrorf() — fiber Function Reference

NewErrorf() — fiber Function Reference

Architecture documentation for the NewErrorf() function in app.go from the fiber codebase.

Entity Profile

Dependency Diagram

graph TD
  40140355_282c_0830_dbfb_efb62d467eaa["NewErrorf()"]
  258982c0_9752_bf98_01ce_836d4de563e1["app.go"]
  40140355_282c_0830_dbfb_efb62d467eaa -->|defined in| 258982c0_9752_bf98_01ce_836d4de563e1
  style 40140355_282c_0830_dbfb_efb62d467eaa fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

app.go lines 1018–1045

func NewErrorf(code int, message ...any) *Error {
	var msg string

	switch len(message) {
	case 0:
		// nothing to override
		msg = utils.StatusMessage(code)

	case 1:
		// One argument → treat it like fmt.Sprint(arg)
		if s, ok := message[0].(string); ok {
			msg = s
		} else {
			msg = fmt.Sprint(message[0])
		}

	default:
		// Two or more → first must be a format string.
		if format, ok := message[0].(string); ok {
			msg = fmt.Sprintf(format, message[1:]...)
		} else {
			// If the first arg isn’t a string, fall back.
			msg = fmt.Sprint(message[0])
		}
	}

	return &Error{Code: code, Message: msg}
}

Domain

Subdomains

Defined In

Frequently Asked Questions

What does NewErrorf() do?
NewErrorf() is a function in the fiber codebase, defined in app.go.
Where is NewErrorf() defined?
NewErrorf() is defined in app.go at line 1018.

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free