mirror of
https://github.com/denoland/deno.git
synced 2024-12-21 23:04:45 -05:00
cli: don't panic on Deno.close invalid argument (#5320)
This commit is contained in:
parent
21a4e9cc58
commit
7de86ab605
2 changed files with 11 additions and 1 deletions
|
@ -1,6 +1,16 @@
|
|||
// Copyright 2018-2020 the Deno authors. All rights reserved. MIT license.
|
||||
import { unitTest, assertEquals, assert } from "./test_util.ts";
|
||||
|
||||
unitTest(function resourcesCloseBadArgs(): void {
|
||||
let err;
|
||||
try {
|
||||
Deno.close((null as unknown) as number);
|
||||
} catch (e) {
|
||||
err = e;
|
||||
}
|
||||
assert(err instanceof Deno.errors.InvalidData);
|
||||
});
|
||||
|
||||
unitTest(function resourcesStdio(): void {
|
||||
const res = Deno.resources();
|
||||
|
||||
|
|
|
@ -31,7 +31,7 @@ fn op_close(
|
|||
struct CloseArgs {
|
||||
rid: i32,
|
||||
}
|
||||
let args: CloseArgs = serde_json::from_value(args).unwrap();
|
||||
let args: CloseArgs = serde_json::from_value(args)?;
|
||||
let mut resource_table = isolate.resource_table.borrow_mut();
|
||||
resource_table
|
||||
.close(args.rid as u32)
|
||||
|
|
Loading…
Reference in a new issue