Skip to content

Commit

Permalink
Instead of directly throwing error, UAC wrapper emits error event
Browse files Browse the repository at this point in the history
when remote reports error message
  • Loading branch information
JLChnToZ committed Dec 31, 2018
1 parent e952bc3 commit 73895e2
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 5 deletions.
5 changes: 3 additions & 2 deletions lib/terminals/uacwrapper.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion lib/terminals/uacwrapper.js.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 3 additions & 2 deletions src/terminals/uacwrapper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ export class UACClient extends TerminalBase<Socket> {
// Create a named pipe for IPC between clones.
const pipe = `uniterm-${process.pid}-${(await randomBytesAsync(16)).toString('hex')}`;
createServer()
.listen(joinPath(`\\\\.\\pipe`, pipe))
.listen(joinPath('\\\\.\\pipe', pipe))
.once('connection', this.handleConnection)
.once('connection', closeServer);
this._pushData('SUDO: Waiting to confirm getting administrator privileges...\r\n');
Expand Down Expand Up @@ -148,7 +148,8 @@ export class UACClient extends TerminalBase<Socket> {
case CMDType.Error:
dataSize += buffer.readUInt32BE(1) + 4;
if(buffer.length < dataSize) return;
throw new Error(`Remote error: ${buffer.toString('utf8', 5, dataSize)}`);
this.emit('error', new Error(`Remote error: ${buffer.toString('utf8', 5, dataSize)}`));
break;
case CMDType.Exit:
dataSize += 4;
if(buffer.length < dataSize) return;
Expand Down

0 comments on commit 73895e2

Please sign in to comment.