From f778fe9f6ec45db9d9ffd105c13dd7fcfc0a047b Mon Sep 17 00:00:00 2001 From: Jon Edvald Date: Thu, 24 May 2018 00:47:55 +0200 Subject: [PATCH] fix: error handling in hello-container --- examples/hello-world/services/hello-container/index.js | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/examples/hello-world/services/hello-container/index.js b/examples/hello-world/services/hello-container/index.js index 18e7c7235a..128eab8e26 100644 --- a/examples/hello-world/services/hello-container/index.js +++ b/examples/hello-world/services/hello-container/index.js @@ -3,12 +3,18 @@ const request = require("request-promise") const app = express() +const functionEndpoint = process.env.GARDEN_SERVICES_HELLO_FUNCTION_ENDPOINT + app.get("/hello", (req, res) => { // Query the example cloud function and return the response - request.get(process.env.GARDEN_SERVICES_HELLO_FUNCTION_ENDPOINT) + request.get(functionEndpoint) .then(response => { res.send(response + "\n") }) + .catch(() => { + res.statusCode = 500 + res.send("Unable to reach function at " + functionEndpoint + "\n") + }) }) // This is the path GAE uses for health checks