luci: Index | Files

package appstatus

import ""

Package appstatus can attach/reterieve an application-specific response status to/from an error. It designed to prevent accidental exposure of internal statuses to RPC clients, for example Spanner's statuses.

TODO(nodir): move the package to luci/grpc if this approach proves useful.


Package Files

doc.go helpers.go status.go

func Attach Uses

func Attach(err error, status *status.Status) error

Attach attaches an application-specific status to the error. The status will be shared with the RPC client as is. If err already has an application-specific status attached, panics.

func Attachf Uses

func Attachf(err error, code codes.Code, format string, args ...interface{}) error

Attachf is a shortcut for Attach(err, status.Newf(...))

func BadRequest Uses

func BadRequest(err error, details ...*errdetails.BadRequest) error

BadRequest annotates err as a bad request. The error message is shared with the requester as is.

func Errorf Uses

func Errorf(code codes.Code, format string, args ...interface{}) error

Errorf returns an error with an application-specific status. The message will be shared with the RPC client as is.

func Get Uses

func Get(err error) (st *status.Status, ok bool)

Get returns an application-specific Status attached to err using this package. If not explicitly set or if err is nil, then ok is false.

Package appstatus imports 5 packages (graph) and is imported by 3 packages. Updated 2020-01-06. Refresh now. Tools for package owners.