aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAdam Soltys <[email protected]>2023-04-13 20:13:36 +0000
committerAdam Soltys <[email protected]>2023-04-13 20:13:38 +0000
commit812a8129251347f236b562417e850ec015cdc65a (patch)
treecca6d0d459684cac920bb2a8805e6109d50bf2ff
parent36cdac82d7b52c6ea02b81afc93ebe2f5f743047 (diff)
downloadcoinos-server-812a8129251347f236b562417e850ec015cdc65a.tar.gz
coinos-server-812a8129251347f236b562417e850ec015cdc65a.zip
log socket errors
-rw-r--r--lib/sockets.js4
-rw-r--r--routes/invoices.js8
2 files changed, 8 insertions, 4 deletions
diff --git a/lib/sockets.js b/lib/sockets.js
index 7be4936b..ba763fdc 100644
--- a/lib/sockets.js
+++ b/lib/sockets.js
@@ -51,7 +51,7 @@ export async function socketServer(app) {
app.get("/ws", { websocket: true }, (connection, req) => {
let { socket: ws } = connection;
- connection.on("error", console.log);
+ connection.on("error", (e) => err(e.message));
const id = v4();
ws.id = id;
@@ -133,7 +133,7 @@ export async function socketServer(app) {
}
});
- ws.on("error", console.log);
+ ws.on("error", (e) => err(e.message));
ws.on("close", function (code, reason) {
try {
diff --git a/routes/invoices.js b/routes/invoices.js
index 8e23e5f1..f55d997f 100644
--- a/routes/invoices.js
+++ b/routes/invoices.js
@@ -1,6 +1,6 @@
import { g, s } from "$lib/db";
import { generate } from "$lib/invoices";
-import { fail, pick } from "$lib/utils";
+import { bail, fail, pick } from "$lib/utils";
import whitelist from "$lib/whitelist";
import got from "got";
import config from "$config";
@@ -33,7 +33,11 @@ export default {
},
async create({ body: { invoice, user }, user: sender }, res) {
- res.send(await generate({ invoice, user, sender }));
+ try {
+ res.send(await generate({ invoice, user, sender }));
+ } catch (e) {
+ bail(res, e.message);
+ }
},
async classic({ params: { username } }, res) {