api

package
v0.8.17 Latest Latest
Warning

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

Go to latest
Published: Apr 25, 2024 License: GPL-3.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrorHandler = func(l ecslogger.ILogger) fiber.ErrorHandler {
	return func(c *fiber.Ctx, err error) error {
		code := fiber.StatusInternalServerError
		var resp interface{}

		var e *fiber.Error
		if errors.As(err, &e) {
			code = e.Code
		} else if apiErr, ok := err.(IError); ok {
			resp = apiErr.Response()
			code = apiErr.StatusCode()
		}

		if resp == nil {
			resp = response.Error(apierror.New(strconv.Itoa(code), err.Error(), code))
		}

		l.Error(c.Path(), err)
		return c.Status(code).JSON(resp)
	}
}

Functions

This section is empty.

Types

type IError

type IError interface {
	response.IError
	StatusCode() int
	Response() interface{}
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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