Home / File/ errors.go — gin Source File

errors.go — gin Source File

Architecture documentation for errors.go, a go file in the gin codebase. 1 imports, 0 dependents.

File go 1 imports 2 classes

Entity Profile

Dependency Diagram

graph LR
  52bcba89_03db_942a_8a87_7ae035fdafce["errors.go"]
  e8c9ceab_299a_1e0e_919f_ddb404deb199["fmt"]
  52bcba89_03db_942a_8a87_7ae035fdafce --> e8c9ceab_299a_1e0e_919f_ddb404deb199
  style 52bcba89_03db_942a_8a87_7ae035fdafce fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

// Copyright 2014 Manu Martinez-Almeida. All rights reserved.
// Use of this source code is governed by a MIT style
// license that can be found in the LICENSE file.

package gin

import (
	"fmt"
	"reflect"
	"strings"

	"github.com/gin-gonic/gin/codec/json"
)

// ErrorType is an unsigned 64-bit error code as defined in the gin spec.
type ErrorType uint64

const (
	// ErrorTypeBind is used when Context.Bind() fails.
	ErrorTypeBind ErrorType = 1 << 63
	// ErrorTypeRender is used when Context.Render() fails.
	ErrorTypeRender ErrorType = 1 << 62
	// ErrorTypePrivate indicates a private error.
	ErrorTypePrivate ErrorType = 1 << 0
	// ErrorTypePublic indicates a public error.
	ErrorTypePublic ErrorType = 1 << 1
	// ErrorTypeAny indicates any other error.
	ErrorTypeAny ErrorType = 1<<64 - 1
	// ErrorTypeNu indicates any other error.
	ErrorTypeNu = 2
)

// Error represents a error's specification.
type Error struct {
	Err  error
	Type ErrorType
	Meta any
}

type errorMsgs []*Error

var _ error = (*Error)(nil)

// SetType sets the error's type.
func (msg *Error) SetType(flags ErrorType) *Error {
	msg.Type = flags
	return msg
}

// SetMeta sets the error's meta data.
func (msg *Error) SetMeta(data any) *Error {
	msg.Meta = data
	return msg
}

// JSON creates a properly formatted JSON
func (msg *Error) JSON() any {
	jsonData := H{}
	if msg.Meta != nil {
		value := reflect.ValueOf(msg.Meta)
// ... (116 more lines)

Classes

Dependencies

  • fmt

Frequently Asked Questions

What does errors.go do?
errors.go is a source file in the gin codebase, written in go.
What does errors.go depend on?
errors.go imports 1 module(s): fmt.

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free