Skip to content
Node: createError(404, msg)github.com/sahilkhaire/gox/err

AppError.NotFound

Overview

Returns a typed 404 error for HTTP handlers — maps to createError(404) from http-errors.

If you are coming from Node.js, the closest pattern is createError(404, msg).

Method on AppError — call it on a value of that type after constructing or receiving one from a constructor.

Signature

go
func NotFound(message string) *AppError

Compare: Node.js · Standard Go · gox

js
next(createError(404, 'not found'));
go
return fmt.Errorf("not found: %w", ErrNotFound)
go
import "github.com/sahilkhaire/gox/err"

return err.NotFound("not found")

Example

go
import "github.com/sahilkhaire/gox/err"

return err.NotFound("not found")

Tips

Return from gox/http handlers; status code is inferred automatically.

Standard library alternative

Use the standard library directly:

go
return fmt.Errorf("not found: %w", ErrNotFound)

Back to err package overview

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