-
-
Notifications
You must be signed in to change notification settings - Fork 12
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
How to get the exception Inner database is not open
?
#109
Comments
9 tasks
I found a way to do this: return await new Promise<DBLevel>((resolve, reject) => {
const dbLevelNew = subleveldown(dbLevel, domain, {
keyEncoding: 'binary',
valueEncoding: 'binary',
open: (cb) => {
// This `cb` is defaulted (hardcoded) to a function that emits an error event
// When using `level`, we are able to provide a callback that overrides this `cb`
// However `subleveldown` does not provide a callback parameter
// It provides this `open` option, which requires us to call `cb` to finish
// If we provide an exception as a parameter, it will be received by the `error` event handler
cb(undefined);
resolve(dbLevelNew);
},
});
// @ts-ignore error event for subleveldown
dbLevelNew.on('error', (e) => {
// Errors during construction of the sublevel will be emitted as events
reject(e);
});
}); It would preferable that Atm even the types think that Now I can actually handle the error properly:
|
10 tasks
On that point: https://github.com/Level/abstract-level |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I've noticed in my codebase when creating the sublevel, internally this error
Inner database is not open
gets thrown.It's immediately applied to the
cb
inside the_open
.When using
subleveldown
, the call itself appears asynchronous.So I have to use the
open
callback to know when thesubleveldown
is fully established.However there doesn't seem to be a way to catch this exception of
Inner database is not open
.I'm also not sure what is causing this exception.
The text was updated successfully, but these errors were encountered: