db: add common errunsupported

This commit is contained in:
mappu 2024-07-06 12:02:58 +12:00
parent 2f65ffdd70
commit 60add3be86
8 changed files with 12 additions and 18 deletions

View File

@ -1,7 +1,6 @@
package main
import (
"errors"
"fmt"
"path/filepath"
"unsafe"
@ -85,7 +84,7 @@ func (ld *badgerLoadedDatabase) RenderForNav(f *TMainForm, ndata *navData) {
}
func (n *badgerLoadedDatabase) ApplyChanges(f *TMainForm, ndata *navData) error {
return errors.New("Editing is not supported")
return ErrNotSupported
}
func (ld *badgerLoadedDatabase) NavChildren(ndata *navData) ([]string, error) {
@ -104,7 +103,7 @@ func (ld *badgerLoadedDatabase) NavContext(ndata *navData) ([]contextAction, err
}
func (ld *badgerLoadedDatabase) ExecQuery(query string, resultArea *vcl.TStringGrid) error {
return errors.New("Badger doesn't support querying")
return ErrNotSupported
}
func (ld *badgerLoadedDatabase) Close() {

View File

@ -186,7 +186,7 @@ func (ld *boltLoadedDatabase) DeleteBucket(ndata *navData) {
}
func (ld *boltLoadedDatabase) ExecQuery(query string, resultArea *vcl.TStringGrid) error {
return errors.New("Bolt doesn't support querying")
return ErrNotSupported
}
func (ld *boltLoadedDatabase) Close() {

View File

@ -1,7 +1,6 @@
package main
import (
"errors"
"fmt"
"os"
"path/filepath"
@ -71,7 +70,7 @@ func (ld *debconfLoadedDatabase) RenderForNav(f *TMainForm, ndata *navData) {
}
func (n *debconfLoadedDatabase) ApplyChanges(f *TMainForm, ndata *navData) error {
return errors.New("Editing is not supported")
return ErrNotSupported
}
func (ld *debconfLoadedDatabase) NavChildren(ndata *navData) ([]string, error) {
@ -90,7 +89,7 @@ func (ld *debconfLoadedDatabase) NavContext(ndata *navData) ([]contextAction, er
}
func (ld *debconfLoadedDatabase) ExecQuery(query string, resultArea *vcl.TStringGrid) error {
return errors.New("debconf doesn't support querying")
return ErrNotSupported
}
func (ld *debconfLoadedDatabase) Close() {

View File

@ -1,8 +1,6 @@
package main
import (
"errors"
"github.com/ying32/govcl/vcl"
)
@ -25,11 +23,11 @@ func (n *noLoadedDatabase) RenderForNav(f *TMainForm, ndata *navData) {
}
func (n *noLoadedDatabase) ApplyChanges(f *TMainForm, ndata *navData) error {
return errors.New("Editing is not supported")
return ErrNotSupported
}
func (n *noLoadedDatabase) ExecQuery(query string, resultArea *vcl.TStringGrid) error {
return nil
return ErrNotSupported
}
func (n *noLoadedDatabase) NavChildren(ndata *navData) ([]string, error) {

View File

@ -2,7 +2,6 @@ package main
import (
"context"
"errors"
"fmt"
"path/filepath"
"unsafe"
@ -76,7 +75,7 @@ func (ld *pebbleLoadedDatabase) RenderForNav(f *TMainForm, ndata *navData) {
}
func (n *pebbleLoadedDatabase) ApplyChanges(f *TMainForm, ndata *navData) error {
return errors.New("Editing is not supported")
return ErrNotSupported
}
func (ld *pebbleLoadedDatabase) NavChildren(ndata *navData) ([]string, error) {
@ -95,7 +94,7 @@ func (ld *pebbleLoadedDatabase) NavContext(ndata *navData) ([]contextAction, err
}
func (ld *pebbleLoadedDatabase) ExecQuery(query string, resultArea *vcl.TStringGrid) error {
return errors.New("pebble doesn't support querying")
return ErrNotSupported
}
func (ld *pebbleLoadedDatabase) Close() {

View File

@ -2,7 +2,6 @@ package main
import (
"context"
"errors"
"fmt"
"strconv"
"unsafe"
@ -139,7 +138,7 @@ func (ld *redisLoadedDatabase) RenderForNav(f *TMainForm, ndata *navData) {
}
func (n *redisLoadedDatabase) ApplyChanges(f *TMainForm, ndata *navData) error {
return errors.New("Editing is not supported")
return ErrNotSupported
}
func (ld *redisLoadedDatabase) NavChildren(ndata *navData) ([]string, error) {

View File

@ -2,7 +2,6 @@ package main
import (
"database/sql"
"errors"
"fmt"
"path/filepath"
"unsafe"
@ -98,7 +97,7 @@ func (ld *sqliteLoadedDatabase) RenderForNav(f *TMainForm, ndata *navData) {
}
func (n *sqliteLoadedDatabase) ApplyChanges(f *TMainForm, ndata *navData) error {
return errors.New("Editing is not supported")
return ErrNotSupported
}
func (ld *sqliteLoadedDatabase) sqliteGetColumnNamesForTable(tableName string) ([]string, error) {

View File

@ -7,6 +7,7 @@ import (
)
var ErrNavNotExist error = errors.New("The selected item no longer exists")
var ErrNotSupported error = errors.New("Unsupported action for this database type")
type contextAction struct {
Name string