Renamed to werr for wrapped error library
This commit is contained in:
parent
0f69874475
commit
4c908f4891
18
problem.go
18
problem.go
@ -2,7 +2,7 @@ package main
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
// External
|
// External
|
||||||
we "git.gibonuddevalla.se/go/wrappederror"
|
werr "git.gibonuddevalla.se/go/wrappederror"
|
||||||
|
|
||||||
// Standard
|
// Standard
|
||||||
"database/sql"
|
"database/sql"
|
||||||
@ -77,7 +77,7 @@ func ProblemsRetrieve() (problems []Problem, err error) { // {{{
|
|||||||
var jsonBody []byte
|
var jsonBody []byte
|
||||||
err = row.Scan(&jsonBody)
|
err = row.Scan(&jsonBody)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
err = we.Wrap(err)
|
err = werr.Wrap(err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -87,7 +87,7 @@ func ProblemsRetrieve() (problems []Problem, err error) { // {{{
|
|||||||
|
|
||||||
err = json.Unmarshal(jsonBody, &problems)
|
err = json.Unmarshal(jsonBody, &problems)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
err = we.Wrap(err)
|
err = werr.Wrap(err)
|
||||||
}
|
}
|
||||||
return
|
return
|
||||||
} // }}}
|
} // }}}
|
||||||
@ -105,7 +105,7 @@ func ProblemStart(trigger Trigger) (problemID int, err error) { // {{{
|
|||||||
var openProblems int
|
var openProblems int
|
||||||
err = row.Scan(&openProblems)
|
err = row.Scan(&openProblems)
|
||||||
if err != nil && err != sql.ErrNoRows {
|
if err != nil && err != sql.ErrNoRows {
|
||||||
err = we.Wrap(err).WithData(trigger.ID)
|
err = werr.Wrap(err).WithData(trigger.ID)
|
||||||
return
|
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)
|
row = service.Db.Conn.QueryRow(`INSERT INTO problem(trigger_id, datapoints) VALUES($1, $2) RETURNING id`, trigger.ID, datapointValuesJson)
|
||||||
err = row.Scan(&problemID)
|
err = row.Scan(&problemID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
err = we.Wrap(err).WithData(trigger)
|
err = werr.Wrap(err).WithData(trigger)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return
|
return
|
||||||
@ -130,7 +130,7 @@ func ProblemClose(trigger Trigger) (problemID int, err error) { // {{{
|
|||||||
}
|
}
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
err = we.Wrap(err).WithData(trigger)
|
err = werr.Wrap(err).WithData(trigger)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
return
|
return
|
||||||
@ -138,13 +138,13 @@ func ProblemClose(trigger Trigger) (problemID int, err error) { // {{{
|
|||||||
func ProblemAcknowledge(id int, state bool) (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)
|
_, err = service.Db.Conn.Exec(`UPDATE problem SET "acknowledged"=$2 WHERE id=$1`, id, state)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
err = we.Wrap(err).WithData(id)
|
err = werr.Wrap(err).WithData(id)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
return
|
return
|
||||||
} // }}}
|
} // }}}
|
||||||
|
|
||||||
func (p Problem) FormattedValues() string {
|
func (p Problem) FormattedValues() string {// {{{
|
||||||
out := []string{}
|
out := []string{}
|
||||||
for key, val := range p.DatapointValues {
|
for key, val := range p.DatapointValues {
|
||||||
var keyval string
|
var keyval string
|
||||||
@ -174,4 +174,4 @@ func (p Problem) FormattedValues() string {
|
|||||||
sort.Strings(out)
|
sort.Strings(out)
|
||||||
|
|
||||||
return strings.Join(out, "\n")
|
return strings.Join(out, "\n")
|
||||||
}
|
}// }}}
|
||||||
|
Loading…
Reference in New Issue
Block a user