weird

package
v0.7.5 Latest Latest
Warning

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

Go to latest
Published: Jul 16, 2024 License: MIT Imports: 1 Imported by: 1

README

Weird error

Yet another error management tool

Usage
package main

import (
	"errors"
	
	"gitlab.com/infiniteloopcloud/weird"
)

var ErrTest = errors.New("test error")

func main() {
	err := weird.New("Message returned over HTTP", ErrTest, 402)
	
	errors.Is(err, ErrTest)
	// returns true
}

Documentation

Overview

Package weird is our internal error handling tool with proper protocol agnostic response definition

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func New

func New(msg string, err error, statusCode int) error

func NewOrElse added in v0.5.2

func NewOrElse(msg string, err error, statusCode int) error

Types

type Error

type Error struct {
	// StatusCode is the final status code returned for http response writer
	StatusCode int

	// Error is the original error
	InnerError error

	// Msg is the final message returned for http response writer
	Msg string
}

Error is the main error handling representation, the usage

func (Error) Error

func (e Error) Error() string

Error satisfy the error interface and format the error

func (Error) Is

func (e Error) Is(target error) bool

Is helps to manage the errors.Is

Jump to

Keyboard shortcuts

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