Skip to content

Commit

Permalink
whitespace
Browse files Browse the repository at this point in the history
  • Loading branch information
mvantellingen committed Oct 15, 2011
1 parent 13ae713 commit e1608f7
Showing 1 changed file with 12 additions and 10 deletions.
22 changes: 12 additions & 10 deletions psycopg2ct/_impl/connection.py
Expand Up @@ -36,6 +36,7 @@ def check_closed_(self, *args, **kwargs):
return func(self, *args, **kwargs)
return check_closed_


def check_notrans(func):
@wraps(func)
def check_notrans_(self, *args, **kwargs):
Expand All @@ -44,6 +45,7 @@ def check_notrans_(self, *args, **kwargs):
return func(self, *args, **kwargs)
return check_notrans_


def check_tpc(func):
@wraps(func)
def check_tpc_(self, *args, **kwargs):
Expand Down Expand Up @@ -693,32 +695,32 @@ def _process_notifies(self):

def _get_exc_type_for_state(self, code):
"""Translate the sqlstate to a relevant exception.
See for a list of possible errors:
http://www.postgresql.org/docs/current/static/errcodes-appendix.html
"""
if code[0] == '0':
# Class 0A - Feature Not Supported
# Class 0A - Feature Not Supported
if code[1] == 'A':
return exceptions.NotSupportedError

elif code[0] == '2':
# Class 21 - Cardinality Violation
if code[1] == '1':
if code[1] == '1':
return exceptions.ProgrammingError

# Class 22 - Data Exception
if code[1] == '2':
if code[1] == '2':
return exceptions.DataError

# Class 23 - Integrity Constraint Violation
if code[1] == '3':
if code[1] == '3':
return exceptions.IntegrityError

# Class 24 - Invalid Cursor State
# Class 25 - Invalid Transaction State
if code[1] in '45':
if code[1] in '45':
return exceptions.InternalError

# Class 26 - Invalid SQL Statement Name
Expand All @@ -743,7 +745,7 @@ def _get_exc_type_for_state(self, code):
# Class 3B - Savepoint Exception
if code[1] in '89B':
return exceptions.InternalError

# Class 3D - Invalid Catalog Name
# Class 3F - Invalid Schema Name
if code[1] in 'DF':
Expand All @@ -767,10 +769,10 @@ def _get_exc_type_for_state(self, code):
# Class 54 - Program Limit Exceeded
# Class 55 - Object Not In Prerequisite State
# Class 57 - Operator Intervention
# Class 58 - System Error (errors external to PostgreSQL itself)
# Class 58 - System Error (errors external to PostgreSQL itself)
if code in '34578':
return exceptions.OperationalError

elif code[0] == 'F':
# Class F0 - Configuration File Error
return exceptions.InternalError
Expand All @@ -782,7 +784,7 @@ def _get_exc_type_for_state(self, code):
elif code[0] == 'X':
# Class XX - Internal Error
return exceptions.InternalError

# Fallback exception
return exceptions.DatabaseError

Expand Down

0 comments on commit e1608f7

Please sign in to comment.