Skip to content
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

Merged
merged 4 commits into from
Sep 20, 2018
Merged

Output error instead of panic when the given db_backend is not initialised #2411

merged 4 commits into from
Sep 20, 2018

Conversation

bradyjoestar
Copy link
Contributor

refs #2371

Copy link
Contributor

@melekes melekes left a 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:]))
Copy link
Contributor

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]
Copy link
Contributor

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)

@melekes melekes changed the title Issue2371 Output error instead of panic when the given db_backend is not initialised Sep 17, 2018
@codecov-io
Copy link

codecov-io commented Sep 19, 2018

Codecov Report

Merging #2411 into develop will decrease coverage by 0.02%.
The diff coverage is 28.57%.

@@             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
Impacted Files Coverage Δ
libs/db/db.go 43.75% <28.57%> (-16.25%) ⬇️
consensus/state.go 76.55% <0%> (-0.48%) ⬇️
blockchain/pool.go 66.43% <0%> (+0.69%) ⬆️

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 ")))
Copy link
Contributor

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

@melekes melekes merged commit 8aad09d into tendermint:develop Sep 20, 2018
melekes added a commit that referenced this pull request 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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants