-
Notifications
You must be signed in to change notification settings - Fork 2.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Output error instead of panic when the given db_backend is not initialised #2411
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for contributing! A few minor changes need to be made.
libs/db/db.go
Outdated
for types := range backends{ | ||
supportType = supportType + " or " + types | ||
} | ||
panic(fmt.Sprintf("Unknown db_backend %v , expected either%v \n", backend, supportType[3:])) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
panic(fmt.Sprintf("Unknown db_backend
%s, expected either %s", backend, strings.Join(backends, " or ")))
libs/db/db.go
Outdated
@@ -28,6 +28,14 @@ func registerDBCreator(backend DBBackendType, creator dbCreator, force bool) { | |||
} | |||
|
|||
func NewDB(name string, backend DBBackendType, dir string) DB { | |||
_, ok := backends[backend] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
let's assign backends[backend]
to dbCreator
and use it later when initialising db
dbCreator, ok := backends[backend]
db, err := dbCreator(name, dir)
Codecov Report
@@ Coverage Diff @@
## develop #2411 +/- ##
===========================================
- Coverage 60.99% 60.96% -0.03%
===========================================
Files 197 197
Lines 16313 16319 +6
===========================================
- Hits 9950 9949 -1
- Misses 5496 5502 +6
- Partials 867 868 +1
|
libs/db/db.go
Outdated
for k, _ := range backends { | ||
keys = append(keys, string(k)) | ||
} | ||
panic(fmt.Sprintf("Unknown db_backend%s, expected either %s", backend, strings.Join(keys, " or "))) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
missing whitespace after db_backend
refs #2371