Output error instead of panic when the given db_backend is not initialised#2411
Merged
melekes merged 4 commits intotendermint:developfrom Sep 20, 2018
bradyjoestar:issue2371
Merged
Output error instead of panic when the given db_backend is not initialised#2411melekes merged 4 commits intotendermint:developfrom bradyjoestar:issue2371
melekes merged 4 commits intotendermint:developfrom
bradyjoestar:issue2371
Conversation
melekes
suggested changes
Sep 17, 2018
Contributor
melekes
left a comment
There was a problem hiding this comment.
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:])) |
Contributor
There was a problem hiding this comment.
panic(fmt.Sprintf("Unknown db_backend %s, expected either %s", backend, strings.Join(backends, " or ")))
libs/db/db.go
Outdated
| } | ||
|
|
||
| func NewDB(name string, backend DBBackendType, dir string) DB { | ||
| _, ok := backends[backend] |
Contributor
There was a problem hiding this comment.
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
|
melekes
approved these changes
Sep 19, 2018
melekes
reviewed
Sep 19, 2018
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 "))) |
Contributor
There was a problem hiding this comment.
missing whitespace after db_backend
melekes
approved these changes
Sep 20, 2018
xla
pushed a commit
that referenced
this pull request
Sep 20, 2018
kfangw
pushed a commit
to kfangw/blockchain
that referenced
this pull request
Jun 10, 2019
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
refs #2371