Python 2.7 はサポートが終了しており、2026 年 1 月 31 日に
非推奨になります。非推奨になると、過去に組織のポリシーを使用して以前のランタイムのデプロイを再度有効にしていた場合でも、Python 2.7 アプリケーションをデプロイできなくなります。既存の Python 2.7 アプリケーションは、
非推奨日以降も引き続き実行され、トラフィックを受信します。
サポートされている最新バージョンの Python に移行することをおすすめします。
例外
コレクションでコンテンツを整理
必要に応じて、コンテンツの保存と分類を行います。
注: 新しいアプリケーションを作成する際は、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()
- インデックスを必要とするクエリに対応するインデックスが見つからない場合に発生します。インデックスと index.yaml ファイルの管理については、管理コンソールをご覧ください。
- exception NotSavedError()
- オブジェクトのデータストアへの保存(put)を必要とする操作が実行されましたが、オブジェクトが保存されていません。
- exception PropertyError()
- 参照されているモデル プロパティがデータ オブジェクトに存在しません。
- exception ReferencePropertyResolveError()
- ReferenceProperty で参照されているモデルが存在しません。詳細については、リファレンスをご覧ください。
- exception ReservedWordError()
- モデルで定義されているプロパティで、使用できないプロパティ名が使用されています。詳細については、使用できないプロパティ名をご覧ください。
- exception Rollback()
- トランザクションに含まれている関数が、トランザクションをコミットせずにロールバックしようとしていることを示します。トランザクションは、キャッチされない例外が発生するとロールバックされます。この例外クラスは便宜上用意されているもので、関数がトランザクションをロールバックしようとしていて、他の例外に当てはまらない場合に適用されます。
- exception Timeout()
- データストア オペレーションの実行時間が上限を超えると発生します。この例外が発生しても、オペレーションが失敗したとは限りません。
- exception TransactionFailedError()
- トランザクションまたはデータストア オペレーションを再試行してもコミットできなかった場合に発生します。この例外は、競合の発生率が高い場合に発生するのが一般的です。データが他の多くのアプリケーション インスタンスによって同時に更新されているために、規定回数の再試行を経てもトランザクションを commit できなかった場合です。詳細については、トランザクションをご覧ください。
google.appengine.runtime.apiproxy_errors
パッケージは、次の例外クラスを提供します。
- exception CapabilityDisabledError()
-
特定のデータストア機能を利用できないために Datastore API の呼び出しが行われなかったことを示します。
特に記載のない限り、このページのコンテンツはクリエイティブ・コモンズの表示 4.0 ライセンスにより使用許諾されます。コードサンプルは Apache 2.0 ライセンスにより使用許諾されます。詳しくは、Google Developers サイトのポリシーをご覧ください。Java は Oracle および関連会社の登録商標です。
最終更新日 2025-09-04 UTC。
[[["わかりやすい","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 UTC。"],[[["\u003cp\u003eDevelopers are highly recommended to utilize the NDB Client Library for new applications due to its enhanced features like automatic entity caching.\u003c/p\u003e\n"],["\u003cp\u003eThe \u003ccode\u003egoogle.appengine.ext.db\u003c/code\u003e package offers a range of exception classes to handle various errors related to datastore operations, including issues with arguments, filters, keys, properties, and queries.\u003c/p\u003e\n"],["\u003cp\u003eThe \u003ccode\u003egoogle.appengine.runtime.apiproxy_errors\u003c/code\u003e package includes the \u003ccode\u003eCapabilityDisabledError\u003c/code\u003e exception, which signals when a specific datastore functionality is not accessible.\u003c/p\u003e\n"],["\u003cp\u003eSeveral exceptions in \u003ccode\u003egoogle.appengine.ext.db\u003c/code\u003e highlight potential issues in model definition and data consistency, such as \u003ccode\u003eDuplicatePropertyError\u003c/code\u003e, \u003ccode\u003eKindError\u003c/code\u003e, \u003ccode\u003ePropertyError\u003c/code\u003e, \u003ccode\u003eReferencePropertyResolveError\u003c/code\u003e, and \u003ccode\u003eReservedWordError\u003c/code\u003e.\u003c/p\u003e\n"],["\u003cp\u003eThe package provides specific error handling for transaction-related issues with classes like \u003ccode\u003eRollback\u003c/code\u003e, and \u003ccode\u003eTransactionFailedError\u003c/code\u003e to help in situations where a transaction needs to be rolled back, or a transaction could not be committed.\u003c/p\u003e\n"]]],[],null,["# Exceptions\n\n**Note:**\nDevelopers building new applications are **strongly encouraged** to use the\n[NDB Client Library](/appengine/docs/legacy/standard/python/ndb), which has several benefits\ncompared to this client library, such as automatic entity caching via the Memcache\nAPI. If you are currently using the older DB Client Library, read the\n[DB to NDB Migration Guide](/appengine/docs/legacy/standard/python/ndb/db_to_ndb)\n\nThe `google.appengine.ext.db` package provides the following exception classes:\n\nexception Error()\n\n: This is the base class for all exceptions in this package.\n\nexception BadArgumentError()\n: A bad argument was given to a query method.\n\nexception BadFilterError()\n: A filter string in the query is invalid.\n\nexception BadKeyError()\n: The provided key string is not a valid key.\n\nexception BadPropertyError()\n: The property could not be created because its name is not a string.\n\nexception BadQueryError()\n: The query string is not a valid query.\n\nexception BadRequestError()\n: The request to the datastore service has one or more invalid properties. This is possible if a subclass of [Model](/appengine/docs/legacy/standard/python/datastore/modelclass) overrides some methods (such as [kind()](/appengine/docs/legacy/standard/python/datastore/modelclass#Model_kind)) with an incorrect implementation.\n\nexception BadValueError()\n: The property could not be assigned a value because the value is invalid for the property type.\n\nexception ConfigurationError()\n: A property is not configured correctly.\n\nexception DuplicatePropertyError()\n: A model definition has more than one property with the same name.\n\nexception InternalError()\n: There was an error internal to the datastore service. This exception does not necessarily mean that the operation failed.\n\nexception KindError()\n: The application attempted to use a data entity with a model class that does not match the entity.\n\nexception NeedIndexError()\n: Raised when the SDK does not find a matching index for a query that requires one. Check the [Administration Console](/appengine/docs/adminconsole) to manage your indexes and your [index.yaml](/appengine/docs/legacy/standard/python/config/indexconfig#creating_datastore_indexes) file.\n\nexception NotSavedError()\n: An action was performed that requires the object to have been saved (put) to the datastore, but the object is not saved.\n\nexception PropertyError()\n: The referenced model property does not exist on the data object.\n\nexception ReferencePropertyResolveError()\n: The model referenced by a [ReferenceProperty](/appengine/docs/legacy/standard/python/datastore/typesandpropertyclasses#ReferenceProperty) does not exist. See [References](/appengine/docs/legacy/standard/python/datastore/datamodeling#References).\n\nexception ReservedWordError()\n: A model defines a property whose name is disallowed. See [Disallowed Property Names](/appengine/docs/legacy/standard/python/datastore/modelclass#Disallowed_Property_Names).\n\nexception Rollback()\n: Indicates that a function in a transaction wants to roll back the transaction instead of committing it. Any uncaught exception in a transaction will cause the transaction to roll back. This exception class is for convenience, when a function wants to roll back and no other exception applies.\n\nexception Timeout()\n: Raised when the datastore operation exceeds the maximum amount of time allowed for datastore operations. This exception does not necessarily mean that the operation failed.\n\nexception TransactionFailedError()\n: The transaction or datastore operation could not be committed, even after retrying. This is usually caused by a high rate of contention: The data is being updated by many other application instances simultaneously, and this instance could not commit its transaction within a fixed number of retries. See [Transactions](/appengine/docs/legacy/standard/python/datastore/transactions).\n\nThe `google.appengine.runtime.apiproxy_errors` package provides the following exception classes:\n\nexception CapabilityDisabledError()\n\n: Indicates that a datastore api call was not performed as that particular datastore functionality is not available."]]