https_fn.HttpsError::message 没有真正显示

作者: elbee19创建于 2024年6月2日更新于 2024年6月2日

我正在测试一个第二代 Python firebase 函数,定义如下: @https_fn.on_call( cors=options.CorsOptions( cors_origins=["xxx"], cors_methods=["get", "post"], ) ) def new_gift(req: https_fn.Request) -> https_fn.Response: logger.info("Request Headers:", dict(req.headers))

如果 req.authorization 为 None,则会抛出 HttpsError,使客户端获得错误详细信息。 raise https_fn.HttpsError( code=https_fn.FunctionsErrorCode.FAILED_PRECONDITION, message="This never shows up anywhere!" )

内容来源: firebase/functions-samples