importendpointsimporthttplibclassConflictException(endpoints.ServiceException):"""Conflict exception that is mapped to a 409 response."""http_status=httplib.CONFLICT
[[["容易理解","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\u003eEndpoints Frameworks allows for the use of common HTTP status codes to indicate the success or failure of API requests, such as using a \u003ccode\u003e404\u003c/code\u003e error to indicate an entity does not exist.\u003c/p\u003e\n"],["\u003cp\u003eSpecific exceptions, like \u003ccode\u003eBadRequestException\u003c/code\u003e, \u003ccode\u003eUnauthorizedException\u003c/code\u003e, \u003ccode\u003eForbiddenException\u003c/code\u003e, \u003ccode\u003eNotFoundException\u003c/code\u003e, and \u003ccode\u003eInternalServerErrorException\u003c/code\u003e, are provided by the endpoints library and correspond to specific HTTP error codes.\u003c/p\u003e\n"],["\u003cp\u003eOnly a subset of HTTP status codes are supported, where HTTP \u003ccode\u003e200\u003c/code\u003e or \u003ccode\u003e204\u003c/code\u003e is used for success, 3xx codes result in a \u003ccode\u003e404\u003c/code\u003e error, specific 4xx codes are supported, and all 5xx codes are converted to \u003ccode\u003e503\u003c/code\u003e.\u003c/p\u003e\n"],["\u003cp\u003eUncaught exceptions in the application will result in an HTTP \u003ccode\u003e503\u003c/code\u003e error from the backend API.\u003c/p\u003e\n"],["\u003cp\u003eCustom exception classes for other HTTP status codes can be made by subclassing \u003ccode\u003eendpoints.ServiceException\u003c/code\u003e, as shown in the example of creating a \u003ccode\u003eConflictException\u003c/code\u003e for an HTTP 409 status code.\u003c/p\u003e\n"]]],[],null,["# Exceptions and HTTP status codes\n\nIn many situations, you might want to use common HTTP status codes to indicate\nthe success or failure of a user's API request. For example, if a user is\nattempting to retrieve an entity which doesn't exist, you might want to send an\nHTTP `404` status code to say that no entity with the ID `entity_id` exists.\n| **Important:** An uncaught exception in your application results in an HTTP `503` error from your backend API.\n\nYou can send such common HTTP status codes by raising an exception provided\nby the endpoints library as follows: \n\n message = 'No entity with the id \"%s\" exists.' % entity_id\n raise endpoints.NotFoundException(message)\n\nExceptions provided by Endpoints Frameworks\n-------------------------------------------\n\nThe endpoints library provides the following exceptions, corresponding to\nspecific HTTP status codes:\n\nSupported HTTP status codes\n---------------------------\n\nCloud Endpoints Frameworks supports a subset of HTTP status codes\nin API responses. The following table describes the supported codes.\n\n| **Important:** Don't use custom exception classes to return HTTP 2xx codes. Endpoints Frameworks doesn't support returning HTTP `201` or any other 2xx codes except HTTP `200` and HTTP `204` as described in the preceding table.\n\nCreating your own exception classes\n-----------------------------------\n\nIf you want to create other exception classes for other HTTP status codes, you\ncan do so by subclassing `endpoints.ServiceException`. The following snippet\nshows how to create an exception class that represents an HTTP 409 status code: \n\n import endpoints\n import httplib\n\n class ConflictException(endpoints.ServiceException):\n \"\"\"Conflict exception that is mapped to a 409 response.\"\"\"\n http_status = httplib.CONFLICT"]]