formatter

package
v0.9.51 Latest Latest
Warning

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

Go to latest
Published: Oct 26, 2023 License: MIT Imports: 1 Imported by: 0

Documentation

Overview

Package formatter implements formatters and helper types for err2. See more information from err2.SetFormatter.

Index

Constants

This section is empty.

Variables

View Source
var (
	// Decamel is preimplemented and default formatter to produce human
	// readable error strings from function names.
	//   func CopyFile(..)  -> "copy file: file not exists"
	//                          ^-------^ -> generated from CopyFile
	Decamel = &Formatter{DoFmt: str.Decamel}

	// Noop is preimplemented formatter that does nothing to function name.
	//   func CopyFile(..)  -> "CopyFile: file not exists"
	//                          ^------^ -> function name as it is: CopyFile
	Noop = &Formatter{DoFmt: func(i string) string { return i }}
)

Functions

This section is empty.

Types

type DoFmt

type DoFmt func(i string) string

DoFmt is a helper function type which allows reuse Formatter struct for the implementations.

type Formatter

type Formatter struct {
	DoFmt
}

Formatter is a helper struct which wraps the actual formatting function which is called during the function name processing to produce errors automatically.

func (*Formatter) Format

func (f *Formatter) Format(input string) string

Format just calls function set in the DoFmt field.

type Interface

type Interface interface {
	Format(input string) string
}

Interface is a formatter interface. The implementers are used for automatic error message generation from function names. See more information from err2.Handle.

Jump to

Keyboard shortcuts

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