FormatError returns err as a WTF error, if possible. Otherwise returns the original error.
(err error)
| 302 | // FormatError returns err as a WTF error, if possible. |
| 303 | // Otherwise returns the original error. |
| 304 | func FormatError(err error) error { |
| 305 | if err == nil { |
| 306 | return nil |
| 307 | } |
| 308 | |
| 309 | switch err.Error() { |
| 310 | case "UNIQUE constraint failed: dial_memberships.dial_id, dial_memberships.user_id": |
| 311 | return wtf.Errorf(wtf.ECONFLICT, "Dial membership already exists.") |
| 312 | default: |
| 313 | return err |
| 314 | } |
| 315 | } |
| 316 | |
| 317 | // logstr is a helper function for printing and returning a string. |
| 318 | // It can be useful for printing out query text. |
no test coverage detected