puerta/internal/errors/errors.go

16 lines
312 B
Go
Raw Normal View History

2022-12-30 06:51:51 +00:00
// SPDX-License-Identifier: Apache-2.0
// Copyright © 2022 Roberto Hidalgo <nidito@un.rob.mx>
package errors
type HTTPError interface {
Error() string
Code() int
}
func ToHTTP(err error) (string, int) {
if err := err.(HTTPError); err != nil {
return err.Error(), err.Code()
}
return err.Error(), 500
}