mirror of
https://github.com/matrix-org/matrix-rust-sdk.git
synced 2026-05-04 22:15:44 -04:00
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:
@@ -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.
|
||||
|
||||
7
crates/matrix-sdk-crypto-nodejs/tests/machine.test.js
Normal file
7
crates/matrix-sdk-crypto-nodejs/tests/machine.test.js
Normal file
@@ -0,0 +1,7 @@
|
||||
const { OlmMachine } = require('../');
|
||||
|
||||
describe(OlmMachine.name, () => {
|
||||
test('cannot be instantiated', () => {
|
||||
expect(() => { new OlmMachine() }).toThrow();
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user