如何从 App Engine 服务器获取错误消息?
How to get an error message from an App Engine server?
我正在运行使用这个端点连接一个简单的 Node Express 服务器
app.get('/', (req, res) => {
res.send("Success!");
});
当我在本地或通过 App Engine 运行 此服务器并联系端点时,我收到了预期的响应 "Success!"。
为确保我能收到错误消息,我将端点更改为
app.get('/', (req, res) => {
throw new Error("A useful error message")
});
当我在本地 运行 此服务器并联系端点时,我按预期收到消息 Error: A useful error message
。但是当我 运行 带有 App Engine 的服务器并联系端点时,我收到消息 Internal Server Error
。有没有办法让 App Engine return 我从服务器抛出的特定错误消息?
您可以在 Stackdriver Logging 上查看错误消息:
Error: A useful error message at app.get (/srv/app.js:32:9) at Layer.handle [as handle_request] (/srv/node_modules/express/lib/router/layer.js:95:5) at next (/srv/node_modules/express/lib/router/route.js:137:13) at Route.dispatch (/srv/node_modules/express/lib/router/route.js:112:3) at Layer.handle [as handle_request] (/srv/node_modules/express/lib/router/layer.js:95:5) at /srv/node_modules/express/lib/router/index.js:281:22 at Function.process_params (/srv/node_modules/express/lib/router/index.js:335:12) at next (/srv/node_modules/express/lib/router/index.js:275:10) at expressInit (/srv/node_modules/express/lib/middleware/init.js:40:5) at Layer.handle [as handle_request] (/srv/node_modules/express/lib/router/layer.js:95:5)
或者您可以 运行 :
gcloud app logs read --limit 5
Error: A useful error message at app.get (/srv/app.js:32:9) at Layer.handle [as handle_request] (/srv/node_modules/express/lib/router/layer.js:95:5) at next (/srv/node_modules/express/lib/router/route.js:137:13) at Route.dispatch (/srv/node_modules/express/lib/router/route.js:112:3) at Layer.handle [as handle_request] (/srv/node_modules/express/lib/router/layer.js:95:5) at /srv/node_modules/express/lib/router/index.js:281:22 at Function.process_params (/srv/node_modules/express/lib/router/index.js:335:12) at next (/srv/node_modules/express/lib/router/index.js:275:10) at expressInit (/srv/node_modules/express/lib/middleware/init.js:40:5) at Layer.handle [as handle_request] (/srv/node_modules/express/lib/router/layer.js:95:5)
我正在运行使用这个端点连接一个简单的 Node Express 服务器
app.get('/', (req, res) => {
res.send("Success!");
});
当我在本地或通过 App Engine 运行 此服务器并联系端点时,我收到了预期的响应 "Success!"。
为确保我能收到错误消息,我将端点更改为
app.get('/', (req, res) => {
throw new Error("A useful error message")
});
当我在本地 运行 此服务器并联系端点时,我按预期收到消息 Error: A useful error message
。但是当我 运行 带有 App Engine 的服务器并联系端点时,我收到消息 Internal Server Error
。有没有办法让 App Engine return 我从服务器抛出的特定错误消息?
您可以在 Stackdriver Logging 上查看错误消息:
Error: A useful error message at app.get (/srv/app.js:32:9) at Layer.handle [as handle_request] (/srv/node_modules/express/lib/router/layer.js:95:5) at next (/srv/node_modules/express/lib/router/route.js:137:13) at Route.dispatch (/srv/node_modules/express/lib/router/route.js:112:3) at Layer.handle [as handle_request] (/srv/node_modules/express/lib/router/layer.js:95:5) at /srv/node_modules/express/lib/router/index.js:281:22 at Function.process_params (/srv/node_modules/express/lib/router/index.js:335:12) at next (/srv/node_modules/express/lib/router/index.js:275:10) at expressInit (/srv/node_modules/express/lib/middleware/init.js:40:5) at Layer.handle [as handle_request] (/srv/node_modules/express/lib/router/layer.js:95:5)
或者您可以 运行 :
gcloud app logs read --limit 5
Error: A useful error message at app.get (/srv/app.js:32:9) at Layer.handle [as handle_request] (/srv/node_modules/express/lib/router/layer.js:95:5) at next (/srv/node_modules/express/lib/router/route.js:137:13) at Route.dispatch (/srv/node_modules/express/lib/router/route.js:112:3) at Layer.handle [as handle_request] (/srv/node_modules/express/lib/router/layer.js:95:5) at /srv/node_modules/express/lib/router/index.js:281:22 at Function.process_params (/srv/node_modules/express/lib/router/index.js:335:12) at next (/srv/node_modules/express/lib/router/index.js:275:10) at expressInit (/srv/node_modules/express/lib/middleware/init.js:40:5) at Layer.handle [as handle_request] (/srv/node_modules/express/lib/router/layer.js:95:5)