Skip to content

Commit 2955b7b

Browse files
authoredMay 25, 2017
Merge pull request #24 from cs50/exception-changes
Exception changes
2 parents f98662b + 2230609 commit 2955b7b

File tree

2 files changed

+7
-12
lines changed

2 files changed

+7
-12
lines changed
 

‎setup.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,5 +15,5 @@
1515
name="cs50",
1616
packages=["cs50"],
1717
url="https://github.com/cs50/python-cs50",
18-
version="2.1.0"
18+
version="2.2.0"
1919
)

‎src/cs50/sql.py

+6-11
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import datetime
2+
import importlib
23
import logging
34
import re
45
import sqlalchemy
@@ -17,13 +18,13 @@ def __init__(self, url, **kwargs):
1718
http://docs.sqlalchemy.org/en/latest/core/engines.html#sqlalchemy.create_engine
1819
http://docs.sqlalchemy.org/en/latest/dialects/index.html
1920
"""
21+
22+
# log statements to standard error
2023
logging.basicConfig(level=logging.DEBUG)
2124
self.logger = logging.getLogger(__name__)
22-
try:
23-
self.engine = sqlalchemy.create_engine(url, **kwargs)
24-
except Exception as e:
25-
e.__cause__ = None
26-
raise RuntimeError(e)
25+
26+
# create engine, raising exception if back end's module not installed
27+
self.engine = sqlalchemy.create_engine(url, **kwargs)
2728

2829
def execute(self, text, **params):
2930
"""
@@ -138,9 +139,3 @@ def process(value):
138139
# if constraint violated, return None
139140
except sqlalchemy.exc.IntegrityError:
140141
return None
141-
142-
# else raise exception
143-
except Exception as e:
144-
_e = RuntimeError(e) # else Python 3 prints warnings' tracebacks
145-
_e.__cause__ = None
146-
raise _e

0 commit comments

Comments
 (0)
Please sign in to comment.