fix(crypto-nodejs): OlmMachine.new effectively raises an error.

Returning an `napi::Error` doesn't raise it. We must return a
`Result<_, napi::Error>` to ensure `napi` will raise the error as
expected.
This commit is contained in:
Ivan Enderlin
2022-06-02 15:23:25 +02:00
parent 02802e9088
commit 0d66480cd6
2 changed files with 11 additions and 2 deletions

View File

@@ -62,8 +62,10 @@ impl OlmMachine {
/// asynchronous. Please use the `finalize` method.
#[napi(constructor)]
#[allow(clippy::new_ret_no_self)]
pub fn new() -> napi::Error {
napi::Error::from_reason("To build an `OldMachine`, please use the `initialize` method")
pub fn new() -> Result<(), napi::Error> {
Err(napi::Error::from_reason(
"To build an `OldMachine`, please use the `initialize` method",
))
}
/// The unique user ID that owns this `OlmMachine` instance.

View File

@@ -0,0 +1,7 @@
const { OlmMachine } = require('../');
describe(OlmMachine.name, () => {
test('cannot be instantiated', () => {
expect(() => { new OlmMachine() }).toThrow();
});
});