capture caught exceptions (#37)

* capture caught exceptions

* fix package.json typo
This commit is contained in:
Dustin Decker 2023-01-31 07:52:31 -08:00 committed by GitHub
parent 52ae82a5cc
commit 1b7aa3258c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 8 additions and 4 deletions

10
api.js
View file

@ -22,6 +22,7 @@ const get_hashed_password = require('./utils.js').get_hashed_password;
const get_secure_random_string = require('./utils.js').get_secure_random_string;
const {google} = require('googleapis');
const {OAuth2Client} = require('google-auth-library');
const Sentry = require('@sentry/node');
const SCREENSHOTS_DIR = path.resolve(process.env.SCREENSHOTS_DIR);
@ -200,7 +201,8 @@ async function set_up_api_server(app) {
req.session.authenticated = true;
res.redirect("/app/");
} catch (error) {
console.log(`Error Occured: ${error}`);
console.error(`Error Occured: ${error}`);
Sentry.captureException(error);
res.status(500).send("Error Occured. We're seeing a lot of traffic now. Please try again soon.");
}
});
@ -228,10 +230,11 @@ async function set_up_api_server(app) {
res.set('Content-Encoding', 'gzip');
res.set('Content-Type', 'image/png');
res.send(image);
} catch (error) {
} catch (error) {
console.error(error);
Sentry.captureException(error);
res.status(404).send(`Error retrieving image from GCS`);
}
}
}else{
const image_exists = await check_file_exists(gz_image_path);
@ -617,6 +620,7 @@ async function set_up_api_server(app) {
}).end();
return
}
Sentry.captureException(e);
res.status(200).json({
"success": false,
"error": "An unexpected error occurred.",

View file

@ -38,6 +38,6 @@
"vue-moment": "^4.1.0"
},
"devDependencies": {
"jest": "^29.4.1",
"jest": "^29.4.1"
}
}