jexia / semaphore

Take control of your data, connect with anything, and expose it anywhere through protocols such as HTTP, GraphQL, and gRPC.

Home Page:https://jexia.github.io/semaphore/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Remove usage of trace package

jeroenrinzema opened this issue · comments

The trace package has been used to construct error messages for unexpected behavior. The trace package is to be replaced with error wrapping and custom error types. Any last references to this package could be find by searching for trace.New inside the project.

Custom errors could implement the pretty interface to describe detailed information about the given error.

// ErrUndefinedFunction occurs when custom function is not defined in property but referenced
type ErrUndefinedFunction struct {
	Function string
	Property string
}

// Error returns a description of the given error as a string
func (e ErrUndefinedFunction) Error() string {
	return fmt.Sprintf("undefined custom function '%s' in '%s'", e.Function, e.Property)
}

// Prettify returns the prettified version of the given error
func (e ErrUndefinedFunction) Prettify() prettyerr.Error {
	return prettyerr.Error{
		Code:    "UndefinedFunction",
		Message: e.Error(),
		Details: map[string]interface{}{
			"Function": e.Function,
			"Property": e.Property,
		},
	}
}

Hi @jeroenrinzema,
Can I work on this one?

Hi @ahmedkrmn, sounds great! Feel free to open a PR once you are done.

Implemented by #166