liquid_feedback_core

changeset 463:88b47f0dacde

Use ERRCODE and HINT when raising exceptions
author jbe
date Fri Mar 18 23:34:45 2016 +0100 (2016-03-18)
parents e9525f069607
children 913f4d0b1e6e
files core.sql
line diff
     1.1 --- a/core.sql	Thu Mar 17 03:15:39 2016 +0100
     1.2 +++ b/core.sql	Fri Mar 18 23:34:45 2016 +0100
     1.3 @@ -1472,10 +1472,9 @@
     1.4        IF NOT EXISTS (
     1.5          SELECT NULL FROM "initiative" WHERE "issue_id" = NEW."id"
     1.6        ) THEN
     1.7 -        --RAISE 'Cannot create issue without an initial initiative.' USING
     1.8 -        --  ERRCODE = 'integrity_constraint_violation',
     1.9 -        --  HINT    = 'Create issue, initiative, and draft within the same transaction.';
    1.10 -        RAISE EXCEPTION 'Cannot create issue without an initial initiative.';
    1.11 +        RAISE EXCEPTION 'Cannot create issue without an initial initiative.' USING
    1.12 +          ERRCODE = 'integrity_constraint_violation',
    1.13 +          HINT    = 'Create issue, initiative, and draft within the same transaction.';
    1.14        END IF;
    1.15        RETURN NULL;
    1.16      END;
    1.17 @@ -1528,10 +1527,9 @@
    1.18        IF NOT EXISTS (
    1.19          SELECT NULL FROM "draft" WHERE "initiative_id" = NEW."id"
    1.20        ) THEN
    1.21 -        --RAISE 'Cannot create initiative without an initial draft.' USING
    1.22 -        --  ERRCODE = 'integrity_constraint_violation',
    1.23 -        --  HINT    = 'Create issue, initiative and draft within the same transaction.';
    1.24 -        RAISE EXCEPTION 'Cannot create initiative without an initial draft.';
    1.25 +        RAISE EXCEPTION 'Cannot create initiative without an initial draft.' USING
    1.26 +          ERRCODE = 'integrity_constraint_violation',
    1.27 +          HINT    = 'Create issue, initiative and draft within the same transaction.';
    1.28        END IF;
    1.29        RETURN NULL;
    1.30      END;
    1.31 @@ -1584,7 +1582,9 @@
    1.32        IF NOT EXISTS (
    1.33          SELECT NULL FROM "opinion" WHERE "suggestion_id" = NEW."id"
    1.34        ) THEN
    1.35 -        RAISE EXCEPTION 'Cannot create a suggestion without an opinion.';
    1.36 +        RAISE EXCEPTION 'Cannot create a suggestion without an opinion.' USING
    1.37 +          ERRCODE = 'integrity_constraint_violation',
    1.38 +          HINT    = 'Create suggestion and opinion within the same transaction.';
    1.39        END IF;
    1.40        RETURN NULL;
    1.41      END;
    1.42 @@ -1737,7 +1737,8 @@
    1.43              RETURN NULL;  -- allows changing of voter comment
    1.44            END IF;
    1.45          END IF;
    1.46 -        RAISE EXCEPTION 'Tried to modify data after voting has been closed.';
    1.47 +        RAISE EXCEPTION 'Tried to modify data after voting has been closed.' USING
    1.48 +          ERRCODE = 'integrity_constraint_violation';
    1.49        END IF;
    1.50        RETURN NULL;
    1.51      END;
    1.52 @@ -2848,7 +2849,8 @@
    1.53          current_setting('transaction_isolation') NOT IN
    1.54          ('repeatable read', 'serializable')
    1.55        THEN
    1.56 -        RAISE EXCEPTION 'Insufficient transaction isolation level';
    1.57 +        RAISE EXCEPTION 'Insufficient transaction isolation level' USING
    1.58 +          HINT = 'Consider using SET TRANSACTION ISOLATION LEVEL REPEATABLE READ.';
    1.59        END IF;
    1.60        RETURN;
    1.61      END;

Impressum / About Us