Renamed to werr for wrapped error library

This commit is contained in:
Magnus Åhall 2024-07-04 09:25:34 +02:00
parent 0f69874475
commit 4c908f4891

View File

@ -2,7 +2,7 @@ package main
import (
// External
we "git.gibonuddevalla.se/go/wrappederror"
werr "git.gibonuddevalla.se/go/wrappederror"
// Standard
"database/sql"
@ -77,7 +77,7 @@ func ProblemsRetrieve() (problems []Problem, err error) { // {{{
var jsonBody []byte
err = row.Scan(&jsonBody)
if err != nil {
err = we.Wrap(err)
err = werr.Wrap(err)
return
}
@ -87,7 +87,7 @@ func ProblemsRetrieve() (problems []Problem, err error) { // {{{
err = json.Unmarshal(jsonBody, &problems)
if err != nil {
err = we.Wrap(err)
err = werr.Wrap(err)
}
return
} // }}}
@ -105,7 +105,7 @@ func ProblemStart(trigger Trigger) (problemID int, err error) { // {{{
var openProblems int
err = row.Scan(&openProblems)
if err != nil && err != sql.ErrNoRows {
err = we.Wrap(err).WithData(trigger.ID)
err = werr.Wrap(err).WithData(trigger.ID)
return
}
@ -115,7 +115,7 @@ func ProblemStart(trigger Trigger) (problemID int, err error) { // {{{
row = service.Db.Conn.QueryRow(`INSERT INTO problem(trigger_id, datapoints) VALUES($1, $2) RETURNING id`, trigger.ID, datapointValuesJson)
err = row.Scan(&problemID)
if err != nil {
err = we.Wrap(err).WithData(trigger)
err = werr.Wrap(err).WithData(trigger)
}
}
return
@ -130,7 +130,7 @@ func ProblemClose(trigger Trigger) (problemID int, err error) { // {{{
}
if err != nil {
err = we.Wrap(err).WithData(trigger)
err = werr.Wrap(err).WithData(trigger)
return
}
return
@ -138,13 +138,13 @@ func ProblemClose(trigger Trigger) (problemID int, err error) { // {{{
func ProblemAcknowledge(id int, state bool) (err error) { // {{{
_, err = service.Db.Conn.Exec(`UPDATE problem SET "acknowledged"=$2 WHERE id=$1`, id, state)
if err != nil {
err = we.Wrap(err).WithData(id)
err = werr.Wrap(err).WithData(id)
return
}
return
} // }}}
func (p Problem) FormattedValues() string {
func (p Problem) FormattedValues() string {// {{{
out := []string{}
for key, val := range p.DatapointValues {
var keyval string
@ -174,4 +174,4 @@ func (p Problem) FormattedValues() string {
sort.Strings(out)
return strings.Join(out, "\n")
}
}// }}}