Project

General

Profile

« Previous | Next » 

Revision 5763

sql.py: parse_exception(): DuplicateKeyException: Factored out creation of DuplicateKeyException into helper function

View differences:

sql.py
509 509
        encoding, = match.groups()
510 510
        raise EncodingException(encoding, e)
511 511
    
512
    match = re.match(r'^duplicate key value violates unique constraint "(.+?)"',
513
        msg)
514
    if match:
515
        constraint, = match.groups()
512
    def make_DuplicateKeyException(constraint, e):
516 513
        cols = []
517 514
        cond = None
518 515
        if recover: # need auto-rollback to run index_cols()
......
520 517
                cols = index_cols(db, constraint)
521 518
                cond = index_cond(db, constraint)
522 519
            except NotImplementedError: pass
523
        raise DuplicateKeyException(constraint, cond, cols, e)
520
        return DuplicateKeyException(constraint, cond, cols, e)
524 521
    
522
    match = re.match(r'^duplicate key value violates unique constraint "(.+?)"',
523
        msg)
524
    if match:
525
        constraint, = match.groups()
526
        raise make_DuplicateKeyException(constraint, e)
527
    
525 528
    match = re.match(r'^null value in column "(.+?)" violates not-null'
526 529
        r' constraint', msg)
527 530
    if match:

Also available in: Unified diff