Skip to content

Commit f91c8c0

Browse files
Move exception to own file
1 parent 9e76d0b commit f91c8c0

File tree

3 files changed

+13
-12
lines changed

3 files changed

+13
-12
lines changed

datapoint/Manager.py

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,13 @@
1010

1111
import requests
1212

13-
from .Site import Site
14-
from .Forecast import Forecast
15-
from .Day import Day
16-
from .Timestep import Timestep
17-
from .Element import Element
18-
from .regions.RegionManager import RegionManager
13+
from datapoint.exceptions import APIException
14+
from datapoint.Site import Site
15+
from datapoint.Forecast import Forecast
16+
from datapoint.Day import Day
17+
from datapoint.Timestep import Timestep
18+
from datapoint.Element import Element
19+
from datapoint.regions.RegionManager import RegionManager
1920

2021

2122
if (sys.version_info > (3, 0)):
@@ -72,10 +73,6 @@
7273
}
7374

7475

75-
class DatapointAPIException(Exception):
76-
pass
77-
78-
7976
class Manager(object):
8077
"""
8178
Datapoint Manager object
@@ -106,7 +103,7 @@ def __call_api(self, path, params=None):
106103
try:
107104
data = req.json()
108105
except ValueError:
109-
raise DatapointAPIException("DataPoint has not returned any data, this could be due to an incorrect API key")
106+
raise APIException("DataPoint has not returned any data, this could be due to an incorrect API key")
110107
self.call_response = data
111108
if req.status_code != 200:
112109
msg = [data[m] for m in ("message", "error_message", "status") \

datapoint/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
import os.path
88

9-
from .Manager import Manager
9+
from datapoint.Manager import Manager
1010
import datapoint.profile
1111

1212

datapoint/exceptions.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
class APIException(Exception):
2+
"""When Datapoint returns a broken API response."""
3+
4+
pass

0 commit comments

Comments
 (0)