Skip to content

Commit

Permalink
Merge pull request #16 from c3g/fix/session-creation-errors
Browse files Browse the repository at this point in the history
fix: don't leak command failed errors + remove stack returns
  • Loading branch information
davidlougheed authored Jan 18, 2024
2 parents d5d8f54 + bf816cd commit f0d6b52
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 5 deletions.
6 changes: 3 additions & 3 deletions epivar-prod/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ services:
# Common -------------------------------------------------------------------------------------------------------------

epivar-portal:
image: ghcr.io/c3g/epivar-portal:pr-15
image: ghcr.io/c3g/epivar-portal:edge
ports:
- 80:80
depends_on:
Expand All @@ -18,7 +18,7 @@ services:
# Node 1: hg19 data --------------------------------------------------------------------------------------------------

epivar-node-1-server:
image: ghcr.io/c3g/epivar-server:pr-15
image: ghcr.io/c3g/epivar-server:edge
networks:
- epivar-node-1-server-net
- epivar-node-1-redis-net
Expand Down Expand Up @@ -79,7 +79,7 @@ services:
# Node 2: hg38 data (lifted over) ------------------------------------------------------------------------------------

epivar-node-2-server:
image: ghcr.io/c3g/epivar-server:pr-15
image: ghcr.io/c3g/epivar-server:edge
networks:
- epivar-node-2-server-net
- epivar-node-2-redis-net
Expand Down
16 changes: 14 additions & 2 deletions helpers/handlers.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,27 @@
*/


const GENERIC_MESSAGE =
"An error was encountered while processing this request. See the server logs for more information.";

export const errorHandler = (res, status=500) => err => {
if (status) {
res.status(status);
}

if (err instanceof Error) {
res.json({ok: false, status, message: err.toString(), stack: err.stack.split('\n')});
let message = err.toString();
console.error(`Error encountered (status=${status}): ${message}; stack:\n`, err.stack);
if (message.startsWith("Error: Command failed:")) {
message = GENERIC_MESSAGE;
}
res.json({ok: false, status, message});
} else {
res.json({ok: false, status, message: err});
let message = err;
if (message.startsWith("Error: Command failed:")) {
message = GENERIC_MESSAGE;
}
res.json({ok: false, status, message});
}
res.end();
};
Expand Down

0 comments on commit f0d6b52

Please sign in to comment.