errors

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Jul 2, 2025 License: Apache-2.0 Imports: 4 Imported by: 2

Documentation

Overview

* @Author: nijineko * @Date: 2025-06-08 12:42:57 * @LastEditTime: 2025-06-12 11:10:17 * @LastEditors: nijineko * @Description: noa errors package * @FilePath: \noa\errors\errors.go

* @Author: nijineko * @Date: 2025-06-10 11:30:17 * @LastEditTime: 2025-06-10 11:54:47 * @LastEditors: nijineko * @Description: error stack frame * @FilePath: \noa\errors\stackFrame.go

Index

Constants

This section is empty.

Variables

View Source
var (
	MAX_STACK_DEPTH = 64
)

Functions

func Is

func Is(Err *Error, Target *Error) bool

*

  • @description: Check if the error is of a specific type
  • @param {Error} Err error to check
  • @param {Error} Target target error
  • @return {bool} true if Err is of type Target, false otherwise

func ParseFunction

func ParseFunction(Func *runtime.Func) (string, string)

*

  • @description: Parse runtime.Func to get the package name and function name
  • @param {*runtime.Func} Func runtime function
  • @return {string} package name
  • @return {string} function name

Types

type Error

type Error struct {
	Err   error     // base error
	Stack []uintptr // stack trace
	// contains filtered or unexported fields
}

Error structure

func New

func New(Text string, Skip int) *Error

*

  • @description: Create a new error
  • @param {string} Text error message
  • @param {int} Skip number of stack frames to skip (default is 1)
  • @return {*Error} wrapped error

func Wrap

func Wrap(Err error, Skip int) *Error

*

  • @description: Wrap an error with a stack trace
  • @param {error} Err base error
  • @param {int} Skip number of stack frames to skip
  • @return {*Error} wrapped error with stack trace

func (Error) Error

func (e Error) Error() string

*

  • @description: Get error message
  • @return {string} error message

func (*Error) StackFormat

func (e *Error) StackFormat() string

*

  • @description: Get the stack trace as a formatted string
  • @return {string} formatted stack trace

func (*Error) StackFrames

func (e *Error) StackFrames() []StackFrame

*

  • @description: Get the stack frames of the error
  • @return {[]StackFrame} stack frames

func (*Error) Unwrap

func (e *Error) Unwrap() error

*

  • @description: Unwrap the error to get the original error
  • @return {error} original error

type StackFrame

type StackFrame struct {
	PC           uintptr // Program Counter
	Function     string  // Function name
	File         string  // File name
	Line         int     // Line number
	Entry        uintptr // Entry point of the function
	PackageName  string  // Package name
	FunctionName string  // Function name without package
}

Stack Frame structure

Jump to

Keyboard shortcuts

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