From 53ca0c02b0c399f4cf17a6e0f8a8504e4dde4e91 Mon Sep 17 00:00:00 2001 From: George Hickman Date: Wed, 20 Mar 2013 23:10:24 -0700 Subject: [PATCH] Add PreconditionFailed exception --- rest_framework/exceptions.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/rest_framework/exceptions.py b/rest_framework/exceptions.py index 0c96ecdd5..9ceb64fe1 100644 --- a/rest_framework/exceptions.py +++ b/rest_framework/exceptions.py @@ -88,6 +88,14 @@ class Throttled(APIException): self.detail = detail or self.default_detail +class PreconditionFailed(APIException): + status_code = status.HTTP_412_PRECONDITION_FAILED + default_detail = 'Object has been updated since you retrieved it.' + + def __init__(self, detail=None): + self.detail = detail or self.default_detail + + class ConfigurationError(Exception): """ Indicates an internal server error.