mirror of
https://github.com/marcogll/passkit-generator.git
synced 2026-03-15 13:25:19 +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(
|
||||
async (request: RequestWithBody, response) => {
|
||||
try {
|
||||
if (request.headers["content-type"] !== "application/json") {
|
||||
response.status(400);
|
||||
response.send({
|
||||
@@ -279,8 +280,6 @@ export const pass = functions.https.onRequest(
|
||||
}
|
||||
|
||||
const bufferData = newPass.getAsBuffer();
|
||||
try {
|
||||
console.log("Pass was uploaded successfully.");
|
||||
|
||||
response.set("Content-Type", newPass.mimeType);
|
||||
response.status(200).send(bufferData);
|
||||
@@ -309,6 +308,7 @@ export const pass = functions.https.onRequest(
|
||||
} catch (error) {
|
||||
console.log("Error Uploading pass " + error);
|
||||
|
||||
response.status(500);
|
||||
response.send({
|
||||
explanation: JSON.stringify(error),
|
||||
result: "FAILED",
|
||||
|
||||
Reference in New Issue
Block a user