mirror of
https://github.com/marcogll/passkit-generator.git
synced 2026-03-15 14:25:17 +00:00
Moved everything inside the try-catch and added explicit error code
This commit is contained in:
@@ -58,6 +58,7 @@ declare global {
|
|||||||
|
|
||||||
export const pass = functions.https.onRequest(
|
export const pass = functions.https.onRequest(
|
||||||
async (request: RequestWithBody, response) => {
|
async (request: RequestWithBody, response) => {
|
||||||
|
try {
|
||||||
if (request.headers["content-type"] !== "application/json") {
|
if (request.headers["content-type"] !== "application/json") {
|
||||||
response.status(400);
|
response.status(400);
|
||||||
response.send({
|
response.send({
|
||||||
@@ -279,8 +280,6 @@ export const pass = functions.https.onRequest(
|
|||||||
}
|
}
|
||||||
|
|
||||||
const bufferData = newPass.getAsBuffer();
|
const bufferData = newPass.getAsBuffer();
|
||||||
try {
|
|
||||||
console.log("Pass was uploaded successfully.");
|
|
||||||
|
|
||||||
response.set("Content-Type", newPass.mimeType);
|
response.set("Content-Type", newPass.mimeType);
|
||||||
response.status(200).send(bufferData);
|
response.status(200).send(bufferData);
|
||||||
@@ -309,6 +308,7 @@ export const pass = functions.https.onRequest(
|
|||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.log("Error Uploading pass " + error);
|
console.log("Error Uploading pass " + error);
|
||||||
|
|
||||||
|
response.status(500);
|
||||||
response.send({
|
response.send({
|
||||||
explanation: JSON.stringify(error),
|
explanation: JSON.stringify(error),
|
||||||
result: "FAILED",
|
result: "FAILED",
|
||||||
|
|||||||
Reference in New Issue
Block a user