diff --git a/src/client.ts b/src/client.ts index fd7a5acd..e2039ed6 100644 --- a/src/client.ts +++ b/src/client.ts @@ -243,15 +243,17 @@ export class Client { /** * Kills the adb server. */ - public kill(): Promise { - // TODO try catch - return this.connection() - .catch((error) => { - if (error.code !== 'ECONNREFUSED') { - throw error; - } - }) - .then((conn) => conn && new KillCommand(conn).execute()); + public async kill(): Promise { + try { + await new KillCommand(await this.connection()).execute(); + } catch (error) { + if ( + !(error instanceof Error) || + (error as NodeJS.ErrnoException).code !== 'ECONNREFUSED' + ) { + throw error; + } + } } /**