google

package
v0.0.8 Latest Latest
Warning

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

Go to latest
Published: Jan 23, 2023 License: MIT Imports: 4 Imported by: 0

Documentation

Overview

Package google provides and registers error builders to interpret google errors into gapi errors.

In order to use it, you just need to import this package: import _ "github.com/mwm-io/gapi/errors/google"

Index

Constants

This section is empty.

Variables

View Source
var GrpcCodeErrorBuilder = errors.ErrorBuilderFunc(func(err errors.Error, sourceError error) errors.Error {
	switch status.Code(sourceError) {
	case codes.InvalidArgument:
		err = err.WithStatus(http.StatusNotAcceptable)

	case codes.DeadlineExceeded:
		err = err.WithStatus(http.StatusRequestTimeout)

	case codes.NotFound:
		err = err.WithStatus(http.StatusNotFound)

	case codes.AlreadyExists:
		err = err.WithStatus(http.StatusConflict)

	case codes.PermissionDenied:
		err = err.WithStatus(http.StatusForbidden)

	default:
	}

	return err
})

GrpcCodeErrorBuilder is an ErrorBuilderFunc that will check the grpc status of the sourceErr and set the corresponding http status.

Functions

This section is empty.

Types

This section is empty.

Jump to

Keyboard shortcuts

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