例外狀況
透過集合功能整理內容
你可以依據偏好儲存及分類內容。
附註:我們強烈建議建構新應用程式的開發人員使用 NDB 用戶端程式庫,因為 NDB 用戶端程式庫與本用戶端程式庫相較之下有幾個優點,例如能透過 Memcache API 自動將實體加入快取。如果您目前使用的是舊版的 DB 用戶端程式庫,請參閱從 DB 遷移至 NDB 的指南。
google.appengine.ext.db
套件提供下列的例外狀況類別:
- exception Error()
-
這是本套件中所有例外狀況的基底類別。
- exception BadArgumentError()
- 提供查詢方法不正確的引數。
- exception BadFilterError()
- 查詢中的篩選器字串無效。
- exception BadKeyError()
- 提供的金鑰字串不是有效的金鑰。
- exception BadPropertyError()
- 無法建立屬性,因為屬型名稱不是字串。
- exception BadQueryError()
- 查詢字串不是有效的查詢。
- exception BadRequestError()
- 對資料儲存庫服務的要求有一或多個無效的屬性。當 Model 的子類別以錯誤的方式覆寫某些方法 (例如 kind()) 時,就可能會發生這種例外狀況。
- exception BadValueError()
- 無法將值指派給屬性,因為這個值對該屬性類型而言是無效的。
- exception ConfigurationError()
- 屬性設定不正確。
- exception DuplicatePropertyError()
- 模型定義有一個以上名稱相同的屬性。
- exception InternalError()
- 資料儲存庫服務發生內部錯誤。此異常並不代表作業失敗。
- exception KindError()
- 應用程式嘗試使用之資料實體的模型類別與該實體不相符。
- exception NeedIndexError()
- 當 SDK 沒有為需要索引的查詢找到相符的索引時,就會發生這種例外狀況。請查看「Administration Console」(管理控制台) 以管理您的索引和 index.yaml 檔案。
- exception NotSavedError()
- 執行的動作需要已儲存 (放置) 在資料儲存庫中的物件,但該物件並未儲存。
- exception PropertyError()
- 受參考的模型屬性並不在資料物件中。
- exception ReferencePropertyResolveError()
- ReferenceProperty 所參考的模型並不存在。請參閱參考資料。
- exception ReservedWordError()
- 模型定義之屬性的名稱是不受允許的。詳情請參閱不允許的屬性名稱。
- exception Rollback()
- 代表交易中的某個函式想要復原交易,而非提交交易。任何交易中未偵測到的異常都會導致交易復原。此異常類別發生於函式將復原且沒有其他異常產生時,為了方便起見而設。
- exception Timeout()
- 當資料儲存庫作業的執行時間超出允許的時間上限時,就會出現這種例外狀況。此異常並不代表作業失敗。
- exception TransactionFailedError()
- 無法提交交易或資料儲存庫的作業,即使在重試過也不行。這通常是由於高爭用率導致,資料正在同時經其他應用程式執行個體更新,且此執行個體無法在固定的重試次數中提交其交易。請參閱交易。
google.appengine.runtime.apiproxy_errors
套件提供下列的例外狀況類別:
- exception CapabilityDisabledError()
-
代表某個資料儲存庫 API 呼叫沒有執行,因為特定的資料儲存庫功能無法使用。
除非另有註明,否則本頁面中的內容是採用創用 CC 姓名標示 4.0 授權,程式碼範例則為阿帕契 2.0 授權。詳情請參閱《Google Developers 網站政策》。Java 是 Oracle 和/或其關聯企業的註冊商標。
上次更新時間:2025-06-16 (世界標準時間)。
[[["容易理解","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-06-16 (世界標準時間)。"],[[["Developers are highly recommended to utilize the NDB Client Library for new applications due to its enhanced features like automatic entity caching."],["The `google.appengine.ext.db` package offers a range of exception classes to handle various errors related to datastore operations, including issues with arguments, filters, keys, properties, and queries."],["The `google.appengine.runtime.apiproxy_errors` package includes the `CapabilityDisabledError` exception, which signals when a specific datastore functionality is not accessible."],["Several exceptions in `google.appengine.ext.db` highlight potential issues in model definition and data consistency, such as `DuplicatePropertyError`, `KindError`, `PropertyError`, `ReferencePropertyResolveError`, and `ReservedWordError`."],["The package provides specific error handling for transaction-related issues with classes like `Rollback`, and `TransactionFailedError` to help in situations where a transaction needs to be rolled back, or a transaction could not be committed."]]],[]]