Python 2.7 已終止支援,並將於 2026 年 1 月 31 日
淘汰。淘汰後,您將無法部署 Python 2.7 應用程式,即使貴機構先前曾使用機構政策重新啟用舊版執行階段的部署作業,也無法部署。現有的 Python 2.7 應用程式在
淘汰日期過後,仍會繼續執行並接收流量。建議您
改用系統支援的最新 Python 版本。
Cloud Storage 錯誤與錯誤處理機制
透過集合功能整理內容
你可以依據偏好儲存及分類內容。
Google Cloud Storage 可透過 App Engine UrlFetch
功能來存取,因此可能會出現下列三種錯誤來源:
- App Engine UrlFetch 暫時性錯誤。
- Google Cloud Storage 暫時性錯誤。
- 與值區和物件授權相關的 Google Cloud Storage 錯誤。
Cloud Storage 適用的 App Engine 用戶端程式庫可處理 App Engine 與 Google Cloud Storage 兩端的逾時錯誤,並會自動執行重試,因此您的應用程式不需要新增邏輯來處理這種錯誤。逾時與重試機制的設定會透過 RetryParams 類別發布,您也可以用此類別變更任何一項預設設定,或全數更改。您可以將變更套用至所有函式呼叫,也可以使用函式的 retry_params
參數,指定特定呼叫的變更。
錯誤
Cloud Storage 適用的 App Engine 用戶端程式庫定義了下列錯誤例外狀況類別:
- cloudstorage.Error
-
本套件中所有例外狀況的基本類別。錯誤可能會產生自 App Engine 或 Google Cloud Storage。如需 Google Cloud Storage 的 HTTP 錯誤代碼詳細資訊,請參閱 Google Cloud Storage 說明文件中的 HTTP 狀態和錯誤代碼 。
- cloudstorage.AuthorizationError
- Google Cloud Storage 收到未經授權的要求。如果授權應用程式所使用的存取憑證過期,就可能產生此錯誤。通常 Cloud Storage 適用的 App Engine 用戶端程式庫會自動處理此類錯誤,程式庫會取得新存取憑證並重試要求。
- cloudstorage.ForbiddenError
此類錯誤 (403) 表示 Google Cloud Storage 並未授權該使用者發出要求。
- cloudstorage.NotFoundError
-
HTTP 錯誤 404。您在呼叫
cloudstorage.delete()
、cloudstorage.listbucket()
、cloudstorage.open()
或 cloudstorage.stat()
時指定的資料夾或物件不存在。
- cloudstorage.TimeoutError
-
多次試圖重試後,系統與 Google Cloud Storage 伺服器聯絡仍逾時,就會產生此錯誤。(如需變更預設逾時處理和重試設定的相關資訊,請參閱 RetryParams。
除非另有註明,否則本頁面中的內容是採用創用 CC 姓名標示 4.0 授權,程式碼範例則為阿帕契 2.0 授權。詳情請參閱《Google Developers 網站政策》。Java 是 Oracle 和/或其關聯企業的註冊商標。
上次更新時間:2025-09-04 (世界標準時間)。
[[["容易理解","easyToUnderstand","thumb-up"],["確實解決了我的問題","solvedMyProblem","thumb-up"],["其他","otherUp","thumb-up"]],[["難以理解","hardToUnderstand","thumb-down"],["資訊或程式碼範例有誤","incorrectInformationOrSampleCode","thumb-down"],["缺少我需要的資訊/範例","missingTheInformationSamplesINeed","thumb-down"],["翻譯問題","translationIssue","thumb-down"],["其他","otherDown","thumb-down"]],["上次更新時間:2025-09-04 (世界標準時間)。"],[[["\u003cp\u003eThe App Engine client library for Cloud Storage handles timeout errors and retries automatically, eliminating the need for manual handling in your app.\u003c/p\u003e\n"],["\u003cp\u003eThe \u003ccode\u003eRetryParams\u003c/code\u003e class allows customization of timeout and retry settings, which can be applied globally or to specific function calls.\u003c/p\u003e\n"],["\u003cp\u003eErrors related to Google Cloud Storage access can stem from transient issues, or from bucket and object authorization, in addition to transient errors coming from App Engine \u003ccode\u003eUrlFetch\u003c/code\u003e.\u003c/p\u003e\n"],["\u003cp\u003eThe \u003ccode\u003ecloudstorage\u003c/code\u003e library defines exception classes like \u003ccode\u003eError\u003c/code\u003e, \u003ccode\u003eAuthorizationError\u003c/code\u003e, \u003ccode\u003eForbiddenError\u003c/code\u003e, \u003ccode\u003eNotFoundError\u003c/code\u003e, and \u003ccode\u003eTimeoutError\u003c/code\u003e to handle various error scenarios.\u003c/p\u003e\n"],["\u003cp\u003e\u003ccode\u003eForbiddenError\u003c/code\u003e (403) is common when the bucket permissions (bucket ACL) are not configured properly to allow access from the application.\u003c/p\u003e\n"]]],[],null,["# Cloud Storage Errors and Error Handling\n\nGoogle Cloud Storage is accessed by the App Engine ` UrlFetch ` feature. As a result,\nthere are three sources of possible errors:\n\n- App Engine UrlFetch transient errors.\n- Google Cloud Storage transient errors.\n- Google Cloud Storage errors related to buckets and object authorization.\n\nThe App Engine client library for Cloud Storage handles timeout errors on both the App Engine side and\nthe Google Cloud Storage side and performs retries automatically, so your app does not need to\nadd logic to handle this. The configuration of the timeout and retry mechanism\nis exposed through the [RetryParams](/appengine/docs/legacy/standard/python/googlecloudstorageclient/retryparams_class)\nclass, which you can use to change any or all of the default settings. You can\nmake your changes to apply to all function calls or you can specify changes for\na specific call using the function's `retry_params` parameter.\n\nErrors\n------\n\nThe App Engine client library for Cloud Storage has the following error exception classes defined:\n\ncloudstorage.Error\n\n: The base class for all exceptions in this package. Errors can be\n generated from App Engine or from Google Cloud Storage. For details on HTTP\n error codes from Google Cloud Storage, see\n [HTTP Status and Error\n Codes](/storage/docs/reference-status#standardcodes) in the Google Cloud Storage documentation.\n\ncloudstorage.AuthorizationError\n: An unauthorized request was received by Google Cloud Storage. This error can occur if an\n authorized app is using an access token that has expired. Normally, this error\n is handled automatically in the App Engine client library for Cloud Storage, which gets a new access token\n and retries the request.\n\ncloudstorage.ForbiddenError\n\n: This error (403) indicates that the user was not authorized by Google Cloud Storage to\n make the request.\n\n - The various possible causes for this error are listed in the [Google Cloud Storage error\n documentation](/storage/docs/reference-status#standardcodes) for **403-Forbidden**.\n - A common source of this error is that the bucket permissions (bucket ACL) are not set properly to allow your app access. See [Google Cloud Storage Authentication](/storage/docs/authentication) for information on setting up access.\n\n \u003cbr /\u003e\n\ncloudstorage.NotFoundError\n:\n HTTP error 404. The bucket or object you specified in a call to\n `cloudstorage.delete()`, `cloudstorage.listbucket()`,\n `cloudstorage.open()`,\n or `cloudstorage.stat()` does not exist.\n\ncloudstorage.TimeoutError\n:\n This error is raised when the attempt to contact Google Cloud Storage servers times out even\n after retry attempts. (See\n [RetryParams](/appengine/docs/legacy/standard/python/googlecloudstorageclient/retryparams_class)\n for information on changing the default timeout handling and retries."]]