status

package
v0.3.8 Latest Latest
Warning

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

Go to latest
Published: Nov 25, 2022 License: MIT Imports: 5 Imported by: 9

Documentation

Index

Constants

View Source
const Header = "wl-status"

Variables

View Source
var (
	OK = &T{
		Code: http.StatusOK,
		Desc: "OK",
	}

	NoContent = &T{
		Code: http.StatusNoContent,
		Desc: "no content",
	}

	ErrNotFound = &T{
		Code: http.StatusNotFound,
		Desc: "resource not found",
	}

	ErrRequest = &T{
		Code: http.StatusBadRequest,
		Desc: "bad request",
	}

	ErrMethod = &T{
		Code: http.StatusMethodNotAllowed,
		Desc: "HTTP method not allowed",
	}

	ErrInternal = &T{
		Code: http.StatusInternalServerError,
		Desc: "internal server error",
	}

	ErrUnpaid = &T{
		Code: http.StatusPaymentRequired,
		Desc: "action requires payment",
	}

	ErrForbidden = &T{
		Code: http.StatusForbidden,
		Desc: "action not allowed",
	}

	ErrConflict = &T{
		Code: http.StatusConflict,
		Desc: "action conflicts with existing resource",
	}

	ErrGateway = &T{
		Code: http.StatusBadGateway,
		Desc: "gateway is unreachable or down",
	}

	ErrChallenge = &T{
		Code: http.StatusAccepted,
		Desc: "repeat request with response to challenge in headers",
	}

	ErrUpgrade = &T{
		Code: http.StatusAccepted,
		Desc: "please upgrade your relay to the given version as soon as possible",
	}

	ErrNotImplemented = &T{
		Code: http.StatusNotImplemented,
		Desc: "feature not implemented yet",
	}
)
View Source
var (
	ErrInsufficientBalance      = ErrForbidden.Wrap(CauseInsufficientBalance)
	ErrExpiredPof               = ErrRequest.Wrap(CauseExpiredPof)
	ErrSneakyPof                = ErrRequest.Wrap(CauseSneakyPof)
	ErrInvalidSig               = ErrRequest.Wrap(CauseInvalidSig)
	ErrMissingParam             = ErrRequest.Wrap(CauseMissingParam)
	ErrNoText                   = ErrRequest.Wrap(CauseNoText)
	ErrUnknownFormat            = ErrRequest.Wrap(CauseUnknownFormat)
	ErrVersionMismatch          = ErrRequest.Wrap(CauseVersionMismatch)
	ErrRequestExpired           = ErrRequest.Wrap(CauseRequestExpired)
	ErrSTRejected               = ErrRequest.Wrap(CauseSTRejected)
	ErrWithdrawalPending        = ErrConflict.Wrap(CauseWithdrawalPending)
	ErrWithdrawalInvalid        = ErrRequest.Wrap(CauseWithdrawalInvalid)
	ErrSettlementNotOpen        = ErrRequest.Wrap(CauseSettlementNotOpen)
	ErrSettlementClosed         = ErrRequest.Wrap(CauseSettlementClosed)
	ErrContractPubkeyMismatch   = ErrRequest.Wrap(CauseContractPubkeyMismatch)
	ErrPaymentSystemUnreachable = ErrGateway.Wrap(CausePaymentSystemUnreachable)
	ErrBadEnrollmentKey         = ErrRequest.Wrap(CauseBadEnrollmentKey)
)

Functions

func IsCircuitError

func IsCircuitError(maybe error) bool

func IsRetryable

func IsRetryable(maybe error) (is bool)

TODO increase granularity

Types

type Cause

type Cause string
const (
	CauseInsufficientBalance      Cause = "insufficient balance to complete request"
	CauseExpiredPof               Cause = "expired proof of funding"
	CauseSneakyPof                Cause = "this pof has been seen/used already"
	CauseInvalidSig               Cause = "invalid signature"
	CauseMissingParam             Cause = "missing parameter in URL"
	CauseNoText                   Cause = "format=text is not supported for this field"
	CauseUnknownFormat            Cause = "unknown format"
	CauseVersionMismatch          Cause = "major version mismatch"
	CauseRequestExpired           Cause = "request expired"
	CauseSTRejected               Cause = "sharetoken submission rejected"
	CauseWithdrawalPending        Cause = "a withdrawal is already pending"
	CauseWithdrawalInvalid        Cause = "withdrawal amount is invalid (<= 0)"
	CauseSettlementNotOpen        Cause = "settlement window not yet open"
	CauseSettlementClosed         Cause = "settlement window already closed"
	CauseContractPubkeyMismatch   Cause = "contract public key mismatch"
	CausePaymentSystemUnreachable Cause = "payment system is unreachable or down, please try again later"
	CauseBadEnrollmentKey         Cause = "enrollment key is incorrect"
)

func (Cause) Error

func (c Cause) Error() string

type T

type T struct {
	Code   int    `json:"code"`
	Desc   string `json:"description"`
	Origin string `json:"origin,omitempty"`
	Cause  Cause  `json:"cause,omitempty"`
}

T is an error-compatible type for reporting errors to the API client in a consistent way.

func FromHeader added in v0.2.2

func FromHeader(h http.Header) (*T, error)

func (*T) Error

func (t *T) Error() string

func (*T) Is

func (t *T) Is(maybe error) bool

func (*T) ToHeader added in v0.2.2

func (t *T) ToHeader(h http.Header)

func (*T) Unwrap

func (t *T) Unwrap() error

func (*T) Wrap

func (t *T) Wrap(cause error) *T

func (*T) WriteTo

func (t *T) WriteTo(w io.Writer) (int, error)

Jump to

Keyboard shortcuts

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