errors

package
v1.7.11 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 22, 2026 License: MIT Imports: 7 Imported by: 0

Documentation

Overview

Package errors provides helper functions for handling errors with specific HTTP status codes.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FromGorm added in v1.7.10

func FromGorm(err error, notFound string) error

FromGorm turns a query error into a status error: a missing row is a 404, anything else a 500. notFound is required so the client is not shown gorm's own wording.

Not every missing row is a 404 — GetBookmarks returns an empty list, ResetPassword treats it as success — so this is only for the cases where it is.

func WithStatus

func WithStatus(httpStatus int, err error) error

WithStatus creates a new error with a specific HTTP status code and a given error message. It maps the HTTP status code to a corresponding gRPC status code. If the HTTP status code is not recognized, it logs a warning and uses gRPC's Unknown code. It returns a gRPC error with the mapped gRPC status code and the original error message.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL