File tree Expand file tree Collapse file tree 2 files changed +14
-10
lines changed Expand file tree Collapse file tree 2 files changed +14
-10
lines changed Original file line number Diff line number Diff line change @@ -92,12 +92,16 @@ export class Service implements HostService, AsyncDisposable {
92
92
}
93
93
}
94
94
95
- async waitLoaded ( name : string ) : Promise < void > {
96
- if ( this . #closed) {
97
- throw new Error ( "Service closed" ) ;
95
+ waitLoaded ( name : string ) : Promise < void > {
96
+ try {
97
+ if ( this . #closed) {
98
+ throw new Error ( "Service closed" ) ;
99
+ }
100
+ assertValidPluginName ( name ) ;
101
+ } catch ( e ) {
102
+ return Promise . reject ( e ) ;
98
103
}
99
- assertValidPluginName ( name ) ;
100
- await this . #getWaiter( name ) . promise ;
104
+ return this . #getWaiter( name ) . promise ;
101
105
}
102
106
103
107
interrupt ( reason ?: unknown ) : void {
Original file line number Diff line number Diff line change @@ -10,7 +10,6 @@ import {
10
10
assertRejects ,
11
11
assertStrictEquals ,
12
12
assertStringIncludes ,
13
- assertThrows ,
14
13
} from "jsr:@std/assert@^1.0.1" ;
15
14
import {
16
15
assertSpyCall ,
@@ -1236,22 +1235,23 @@ Deno.test("Service", async (t) => {
1236
1235
} ) ;
1237
1236
1238
1237
await t . step ( ".interrupt()" , async ( t ) => {
1239
- await t . step ( "sends signal to `interrupted` attribute " , ( ) => {
1238
+ await t . step ( "sends signal to `interrupted` property " , ( ) => {
1240
1239
const service = new Service ( meta ) ;
1241
1240
const signal = service . interrupted ;
1242
1241
1243
1242
service . interrupt ( ) ;
1244
1243
1245
- assertThrows ( ( ) => signal . throwIfAborted ( ) ) ;
1244
+ assert ( signal . aborted ) ;
1246
1245
} ) ;
1247
1246
1248
- await t . step ( "sends signal to `interrupted` attribute with reason" , ( ) => {
1247
+ await t . step ( "sends signal to `interrupted` property with reason" , ( ) => {
1249
1248
const service = new Service ( meta ) ;
1250
1249
const signal = service . interrupted ;
1251
1250
1252
1251
service . interrupt ( "test" ) ;
1253
1252
1254
- assertThrows ( ( ) => signal . throwIfAborted ( ) , "test" ) ;
1253
+ assert ( signal . aborted ) ;
1254
+ assertEquals ( signal . reason , "test" ) ;
1255
1255
} ) ;
1256
1256
} ) ;
1257
1257
You can’t perform that action at this time.
0 commit comments