AppError.New
Overview
New creates an AppError with code and message.
Part of the err package — Node.js analog: http-errors.
Method on AppError — call it on a value of that type after constructing or receiving one from a constructor.
Signature
go
func New(code int, message string) *AppErrorCompare: Node.js · Standard Go · gox
js
// Typical http-errors pattern in Node.jsgo
// Use the underlying stdlib or driver directly.
// See package overview for escape hatches.go
import "github.com/sahilkhaire/gox/err"
e := err.AppError.New(404, "not found")Example
go
import "github.com/sahilkhaire/gox/err"
e := err.AppError.New(404, "not found")Tips
Obtain a AppError value first (see constructors on the package overview), then call New.
Standard library alternative
gox wraps the Go standard library or a trusted dependency with Node-familiar naming. You can use the underlying library directly — see the package overview for escape hatches.