mirror of
https://github.com/neilotoole/sq.git
synced 2024-12-18 13:41:49 +03:00
db55986980
- Support for ingest cache, download cache, and progress bars.
26 lines
666 B
Go
26 lines
666 B
Go
package sqlite3
|
|
|
|
import (
|
|
"strings"
|
|
|
|
"github.com/neilotoole/sq/libsq/core/errz"
|
|
"github.com/neilotoole/sq/libsq/driver"
|
|
)
|
|
|
|
// errw wraps any error from the db. It should be called at
|
|
// every interaction with the db. If err is nil, nil is returned.
|
|
// Certain errors will be wrapped in specific error types,
|
|
// e.g, errz.NotExistError.
|
|
func errw(err error) error {
|
|
switch {
|
|
case err == nil:
|
|
return nil
|
|
case strings.HasPrefix(err.Error(), "no such table:"):
|
|
// The sqlite driver always returns sqlite3.ErrError(1), so
|
|
// we need to search by string. Needs further investigation.
|
|
return driver.NewNotExistError(err)
|
|
default:
|
|
return errz.Err(err)
|
|
}
|
|
}
|