feat: optimize websocket client
This commit is contained in:
@@ -20,6 +20,7 @@
|
||||
// USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
|
||||
'use strict';
|
||||
var Throwable = Java.type('java.lang.Throwable')
|
||||
var R = typeof Reflect === 'object' ? Reflect : null
|
||||
var ReflectApply = R && typeof R.apply === 'function'
|
||||
? R.apply
|
||||
@@ -136,13 +137,19 @@ EventEmitter.prototype.emit = function emit(type) {
|
||||
var er;
|
||||
if (args.length > 0)
|
||||
er = args[0];
|
||||
if (er instanceof Error) {
|
||||
if (er instanceof Error || er instanceof Throwable) {
|
||||
// Note: The comments on the `throw` lines are intentional, they show
|
||||
// up in Node's output if this results in an unhandled exception.
|
||||
throw er; // Unhandled 'error' event
|
||||
}
|
||||
if (er.error instanceof Error || er.error instanceof Throwable) {
|
||||
throw er.error; // Unhandled 'error' event
|
||||
}
|
||||
if (er.cause instanceof Error || er.error instanceof Throwable) {
|
||||
throw er.error; // Unhandled 'error' event
|
||||
}
|
||||
// At least give some kind of context to the user
|
||||
var err = new Error('Unhandled error.' + (er ? ' (' + er.message + ')' : ''));
|
||||
var err = new Error('Unhandled error.' + (er ? ' (' + (er.message || er.error || er.cause || er) + ')' : ''));
|
||||
// @ts-ignore
|
||||
err.context = er;
|
||||
throw err; // Unhandled 'error' event
|
||||
|
||||
@@ -5,6 +5,7 @@ const Path = Java.type("java.nio.file.Path");
|
||||
const JavaString = Java.type("java.lang.String");
|
||||
const File = Java.type("java.io.File");
|
||||
const Files = Java.type("java.nio.file.Files");
|
||||
const Paths = Java.type("java.nio.file.Paths");
|
||||
const Collector = Java.type("java.util.stream.Collector")
|
||||
const separatorChar = File.separatorChar;
|
||||
const StandardCopyOption = Java.type("java.nio.file.StandardCopyOption");
|
||||
@@ -37,7 +38,7 @@ function javaFile(...opts: any[]) {
|
||||
}
|
||||
|
||||
export function renameSync(oldPath: PathLike, newPath: PathLike): void {
|
||||
|
||||
Files.move(Paths.get(oldPath), Paths.get(oldPath), StandardCopyOption['ATOMIC_MOVE'])
|
||||
}
|
||||
export function truncateSync() {
|
||||
|
||||
|
||||
Reference in New Issue
Block a user