From cdfac686ef9326d82e4dfd4a659454bfb1a91bdf Mon Sep 17 00:00:00 2001 From: Miguel Beltran Date: Thu, 2 May 2024 12:05:03 +0200 Subject: [PATCH] prettier run --- lib/raygun.ts | 50 +++++++++--------- test/raygun_async_send_test.js | 93 +++++++++++++++++++--------------- 2 files changed, 80 insertions(+), 63 deletions(-) diff --git a/lib/raygun.ts b/lib/raygun.ts index aee17ed..e153a44 100644 --- a/lib/raygun.ts +++ b/lib/raygun.ts @@ -191,26 +191,27 @@ class Raygun { * @param customData to attach to the error report * @param request custom RequestParams * @param tags to attach to the error report + * @return IncomingMessage if message was delivered, null if stored, rejected with Error if failed. */ async send( - exception: Error | string, - customData?: CustomData, - request?: RequestParams, - tags?: Tag[], + exception: Error | string, + customData?: CustomData, + request?: RequestParams, + tags?: Tag[], ): Promise { return new Promise((resolve, reject) => { this.sendWithCallback( - exception, - customData, - function (err, message) { - if (err != null) { - reject(err); - } else { - resolve(message); - } - }, - request, - tags, + exception, + customData, + function (err, message) { + if (err != null) { + reject(err); + } else { + resolve(message); + } + }, + request, + tags, ); }); } @@ -242,11 +243,10 @@ class Raygun { const sendOptions = sendOptionsResult.options; if (this._isOffline) { - let saveCallback = callback ? (err: Error | null) => callVariadicCallback(callback, err, null) : emptyCallback; - this.offlineStorage().save( - JSON.stringify(message), - saveCallback, - ); + let saveCallback = callback + ? (err: Error | null) => callVariadicCallback(callback, err, null) + : emptyCallback; + this.offlineStorage().save(JSON.stringify(message), saveCallback); } else { this.transport().send(sendOptions); } @@ -316,9 +316,13 @@ class Raygun { body: req.body, }; - this.sendWithCallback(err, customData || {}, function () {}, requestParams, [ - "UnhandledException", - ]); + this.sendWithCallback( + err, + customData || {}, + function () {}, + requestParams, + ["UnhandledException"], + ); next(err); } diff --git a/test/raygun_async_send_test.js b/test/raygun_async_send_test.js index f9d0fa8..537cdf6 100644 --- a/test/raygun_async_send_test.js +++ b/test/raygun_async_send_test.js @@ -27,12 +27,15 @@ test("async send basic", {}, function (t) { let client = new Raygun.Client().init({ apiKey: API_KEY, }); - client.send(new Error()).then((response) => { - t.equal(response.statusCode, 202); - t.end(); - }).catch((err) => { - t.fail(err); - }); + client + .send(new Error()) + .then((response) => { + t.equal(response.statusCode, 202); + t.end(); + }) + .catch((err) => { + t.fail(err); + }); }); test("async send complex", {}, function (t) { @@ -49,12 +52,15 @@ test("async send complex", {}, function (t) { .setUser("callum@mindscape.co.nz") .setVersion("1.0.0.0"); - client.send(new Error()).then((response) => { - t.equal(response.statusCode, 202); - t.end(); - }).catch((err) => { - t.fail(err); - }); + client + .send(new Error()) + .then((response) => { + t.equal(response.statusCode, 202); + t.end(); + }) + .catch((err) => { + t.fail(err); + }); }); test("async send with inner error", {}, function (t) { @@ -76,12 +82,15 @@ test("async send with inner error", {}, function (t) { let client = new Raygun.Client().init({ apiKey: API_KEY, }); - client.send(new Error()).then((response) => { - t.equal(response.statusCode, 202); - t.end(); - }).catch((err) => { - t.fail(err); - }); + client + .send(new Error()) + .then((response) => { + t.equal(response.statusCode, 202); + t.end(); + }) + .catch((err) => { + t.fail(err); + }); }); test("async send with verror", {}, function (t) { @@ -101,12 +110,15 @@ test("async send with verror", {}, function (t) { let client = new Raygun.Client().init({ apiKey: API_KEY, }); - client.send(error).then((response) => { - t.equal(response.statusCode, 202); - t.end(); - }).catch((err) => { - t.fail(err); - }); + client + .send(error) + .then((response) => { + t.equal(response.statusCode, 202); + t.end(); + }) + .catch((err) => { + t.fail(err); + }); }); test("async send with OnBeforeSend", {}, function (t) { @@ -128,12 +140,15 @@ test("async send with OnBeforeSend", {}, function (t) { return payload; }); - client.send(new Error()).then((response) => { - t.equal(onBeforeSendCalled, true); - t.end(); - }).catch((err) => { - t.fail(err); - }); + client + .send(new Error()) + .then((response) => { + t.equal(onBeforeSendCalled, true); + t.end(); + }) + .catch((err) => { + t.fail(err); + }); }); test("check that tags get passed through in async send", {}, function (t) { @@ -161,14 +176,12 @@ test("check that tags get merged", {}, function (t) { return payload; }); - client.send( - new Error(), - {}, - null, - ["Tag2"], - ).then((message) => { - t.end(); - }).catch((err) => { - t.fail(err); - }); + client + .send(new Error(), {}, null, ["Tag2"]) + .then((message) => { + t.end(); + }) + .catch((err) => { + t.fail(err); + }); });