ohno

module
v1.0.3 Latest Latest
Warning

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

Go to latest
Published: Jan 2, 2024 License: BSD-3-Clause

README

ohno

godoc_badge

ohno_gopher_gif This repository contains the ohnogen tool and the ohno package. If you have been manually defining error structures and handling them in the past this tool is for you. The ohnogen tool takes line comment annotated enums and turns them into errors which can be passed along and used like any other error. The ohnogen tool is based on the go stringer tool . With this you can define all your error codes and their descriptions as comments and return only the enum as an error from which you can get the description and the name of the error.

The ohno package on the other hand will help you to add more information to an error like source location information (file, line, function) along with timestamps, custom messages, nesting and joining. This also has friendly helper methods to marshal your errors in to json or yaml formats.

You can use either ohnogen tool or the ohno package independently of each other based on your use case subject certain interface constraints being met when using the ohno package standalone which is explained in the ohno package documentation. You can however use the ohnogen tool to generate your errors and use them without the ohno package as long as you don't want additional context being stored in your error.

Go References

Directories

Path Synopsis
cmd
ohnogen
ohnogen is a golang [stringer] based tool to automate the creation of helper methods that provide the name and description of enums(ints only).
ohnogen is a golang [stringer] based tool to automate the creation of helper methods that provide the name and description of enums(ints only).
examples
usage_with_ohno
This example demonstrates how to use the errors generated by [ohnogen] tool when generated with the -ohno flag.
This example demonstrates how to use the errors generated by [ohnogen] tool when generated with the -ohno flag.
usage_without_ohno
This example demonstrates how to use the errors generated by [ohnogen] tool when generated without passing the -ohno flag.
This example demonstrates how to use the errors generated by [ohnogen] tool when generated without passing the -ohno flag.
pkg
ohno
package ohno is a error context addition utility package.
package ohno is a error context addition utility package.
ohnoer
package ohnoer is a package which defines the OhNoer interface.
package ohnoer is a package which defines the OhNoer interface.
sourceinfo
package sourceinfo is a helper around runtime Caller which simplifies fetching source information using frames.
package sourceinfo is a helper around runtime Caller which simplifies fetching source information using frames.

Jump to

Keyboard shortcuts

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