Skip to content

User-defined exceptions as ProgrammingError #360

Open
@rafaelreuber

Description

@rafaelreuber

What kind of database errors are ProgrammingError? If you raise a user-defined exception through the procedure raise_application_error, the cx_Oracle raising an DatabaseError.

I think is more clear use ProgrammingError for user-defined exceptions instead of DatabaseError.

with connection.cursor() as cursor:
    try:
        cursor.execute("begin raise_application_error(-20000, 'Sometime strange thins just happens'); end;")
    except cx_Oracle.ProgrammingError as e:
        print("Yes, you are busines validation error")
    except cx_Oracle.DatabaseError as e:
        print("Hey i'm not a business validation")

Python Version: 3.7.4
cx_Oracle Version: 7.2.2
oracleinstantclient Version: 12.2
Oracle server Version : 11g XE
SO: Fedora 30

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions