31 lines
480 B
Go
Raw Normal View History

2021-06-27 13:31:30 -07:00
package persistence
import (
2021-07-24 12:28:30 -07:00
"fmt"
2021-06-27 13:31:30 -07:00
"errors"
"os"
)
2021-07-24 12:28:30 -07:00
var NotInDatabase = errors.New("Not in database")
type ErrNotInDatabase struct {
Table string
Value interface{}
}
2022-03-06 18:09:43 -08:00
2021-07-24 12:28:30 -07:00
func (err ErrNotInDatabase) Error() string {
return fmt.Sprintf("Not in database: %s %q", err.Table, err.Value)
}
2021-06-27 13:31:30 -07:00
// DUPE 1
func file_exists(path string) bool {
_, err := os.Stat(path)
if err == nil {
return true
} else if errors.Is(err, os.ErrNotExist) {
return false
} else {
panic(err)
}
}