• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

go-fuego / fuego / 13607450952

01 Mar 2025 06:08PM UTC coverage: 91.398% (+0.1%) from 91.255%
13607450952

push

github

web-flow
extra: map SQL and SQLite errors to Fuego HTTP errors (#427)

* feat(sql-sqlite): map SQLite errors to Fuego HTTP errors

* feat(sql-sqlite): map SQL and SQLite errors to Fuego HTTP errors

* feat(sql-sqlite): feedback

* feat(sql-sqlite): format

88 of 92 new or added lines in 2 files covered. (95.65%)

2582 of 2825 relevant lines covered (91.4%)

1.04 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

93.1
/extra/sql/sql_errors.go
1
package sql
2

3
import (
4
        "database/sql"
5
        "errors"
6
        "net/http"
7

8
        "github.com/go-fuego/fuego"
9
)
10

11
// ErrorHandler maps standard SQL errors to the corresponding fuego errors.
12
func ErrorHandler(err error) error {
1✔
13
        if err == nil {
1✔
NEW
14
                return nil
×
NEW
15
        }
×
16

17
        if errors.Is(err, sql.ErrNoRows) {
2✔
18
                return fuego.NotFoundError{
1✔
19
                        Err:    err,
1✔
20
                        Title:  "Record Not Found",
1✔
21
                        Detail: err.Error(),
1✔
22
                        Status: http.StatusNotFound,
1✔
23
                }
1✔
24
        }
1✔
25

26
        if errors.Is(err, sql.ErrConnDone) {
2✔
27
                return fuego.InternalServerError{
1✔
28
                        Err:    err,
1✔
29
                        Title:  "Connection Closed",
1✔
30
                        Detail: err.Error(),
1✔
31
                        Status: http.StatusInternalServerError,
1✔
32
                }
1✔
33
        }
1✔
34

35
        if errors.Is(err, sql.ErrTxDone) {
2✔
36
                return fuego.ConflictError{
1✔
37
                        Err:    err,
1✔
38
                        Title:  "Transaction Completed",
1✔
39
                        Detail: err.Error(),
1✔
40
                        Status: http.StatusConflict,
1✔
41
                }
1✔
42
        }
1✔
43

44
        // For any other error, return the original error.
45
        return err
1✔
46
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc