Skip to content

Commit 31305e1

Browse files
committed
raising ValueError, no longer disconnecting on IntegrityError
1 parent 727df50 commit 31305e1

File tree

1 file changed

+2
-3
lines changed

1 file changed

+2
-3
lines changed

src/cs50/sql.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -385,13 +385,12 @@ def shutdown_session(exception=None):
385385

386386
# If constraint violated, return None
387387
except sqlalchemy.exc.IntegrityError as e:
388-
self._disconnect()
389388
self._logger.debug(termcolor.colored(statement, "yellow"))
390-
e = RuntimeError(e.orig)
389+
e = ValueError(e.orig)
391390
e.__cause__ = None
392391
raise e
393392

394-
# If user errror
393+
# If user error
395394
except (sqlalchemy.exc.OperationalError, sqlalchemy.exc.ProgrammingError) as e:
396395
self._disconnect()
397396
self._logger.debug(termcolor.colored(statement, "red"))

0 commit comments

Comments
 (0)