1
0
Fork 0
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:
Kevin (Kun) "Kassimo" Qian 2020-05-14 03:59:56 -07:00 committed by GitHub
parent 21a4e9cc58
commit 7de86ab605
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 11 additions and 1 deletions

View file

@ -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();

View file

@ -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)