Skip to content
/ caller Public

Wrapping Go errors with a caller name and other helpers

License

Notifications You must be signed in to change notification settings

spirin/caller

Repository files navigation

caller

Wrapping Go errors with a caller name and other helpers

caller.Wrap(err) error - wrap error with caller name. Example

package mypkg

import "github.com/spirin/caller"

func myFunc() error {
    err := doSmth()
    if err != nil {
        // "mypkg.myFunc: some err"
        return caller.Wrap(err)
    }
    ...
}

caller.WrapPackage(err) error - wrap error with caller package name. Example: "http: some err"

package mypkg

import "github.com/spirin/caller"

func myFunc() error {
    err := doSmth()
    if err != nil {
        // "mypkg: some err"
        return caller.WrapPackage(err)
    }
    ...
}

caller.Name() string - get caller name, e.g., "caller.testNameObj.Fn"

caller.NameFull() string - get caller full name, e.g., "testNameFullObj.Fn @ github.com/spirin/caller"

caller.Package() string - get caller package name, e.g., "caller"

About

Wrapping Go errors with a caller name and other helpers

Resources

License

Stars

Watchers

Forks

Packages

No packages published