initial commit

This commit is contained in:
2026-09-01 00:13:01 +01:00
commit efa486fea8
9 changed files with 491 additions and 0 deletions
+50
View File
@@ -0,0 +1,50 @@
package sqaffold
import "net/http"
var (
ErrNoRows = NewError(http.StatusNotFound, "no rows", nil)
)
type Error struct {
StatusCode int
Text string
Previous error
}
func (e *Error) Error() string {
return e.Text
}
func (e *Error) Is(target error) bool {
if other, ok := target.(*Error); ok {
if other.StatusCode > 0 {
if e.StatusCode != other.StatusCode {
return false
}
}
if other.Text != "" {
if e.Text != other.Text {
return false
}
}
}
return true
}
func Err(err error) *Error {
return NewError(http.StatusInternalServerError, err.Error(), err)
}
func NewError(statusCode int, text string, previous error) *Error {
err := &Error{
StatusCode: statusCode,
Text: text,
Previous: previous,
}
return err
}