Skip to content
Node: http-errorsgithub.com/sahilkhaire/gox/err

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) *AppError

Compare: Node.js · Standard Go · gox

js
// Typical http-errors pattern in Node.js
go
// 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.

Back to err package overview

MIT Licensed · Built for Node.js developers moving to Go