Skip to content

Commit 50c6c41

Browse files
author
Shammamah Hossain
authored
Merge pull request #487 from plotly/bare-exceptions
Bare exceptions
2 parents 75a285f + 3a69377 commit 50c6c41

File tree

5 files changed

+24
-7
lines changed

5 files changed

+24
-7
lines changed

CHANGELOG.md

+4
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
## 0.33.0 - 2018-12-10
2+
## Added
3+
- Added specific Dash exception types to replace generic exceptions (InvalidIndexException, DependencyException, ResourceException) [#487](https://github.com/plotly/dash/pull/487)
4+
15
## 0.32.2 - 2018-12-09
26
## Fixed
37
- Fix typo in missing events/inputs error message [#485](https://github.com/plotly/dash/pull/485)

dash/dash.py

+5-5
Original file line numberDiff line numberDiff line change
@@ -275,7 +275,7 @@ def _layout_value(self):
275275
def layout(self, value):
276276
if (not isinstance(value, Component) and
277277
not isinstance(value, collections.Callable)):
278-
raise Exception(
278+
raise exceptions.NoLayoutException(
279279
''
280280
'Layout must be a dash component '
281281
'or a function that returns '
@@ -301,7 +301,7 @@ def index_string(self, value):
301301
)
302302
missing = [missing for check, missing in checks if not check]
303303
if missing:
304-
raise Exception(
304+
raise exceptions.InvalidIndexException(
305305
'Did you forget to include {} in your index string ?'.format(
306306
', '.join('{%' + x + '%}' for x in missing)
307307
)
@@ -475,14 +475,14 @@ def _generate_meta_html(self):
475475
# Serve the JS bundles for each package
476476
def serve_component_suites(self, package_name, path_in_package_dist):
477477
if package_name not in self.registered_paths:
478-
raise exceptions.InvalidResourceError(
478+
raise exceptions.DependencyException(
479479
'Error loading dependency.\n'
480480
'"{}" is not a registered library.\n'
481481
'Registered libraries are: {}'
482482
.format(package_name, list(self.registered_paths.keys())))
483483

484484
elif path_in_package_dist not in self.registered_paths[package_name]:
485-
raise exceptions.InvalidResourceError(
485+
raise exceptions.DependencyException(
486486
'"{}" is registered but the path requested is not valid.\n'
487487
'The path requested: "{}"\n'
488488
'List of registered paths: {}'
@@ -546,7 +546,7 @@ def index(self, *args, **kwargs): # pylint: disable=unused-argument
546546

547547
if missing:
548548
plural = 's' if len(missing) > 1 else ''
549-
raise Exception(
549+
raise exceptions.InvalidIndexException(
550550
'Missing element{pl} {ids} in index.'.format(
551551
ids=', '.join(missing),
552552
pl=plural

dash/exceptions.py

+12
Original file line numberDiff line numberDiff line change
@@ -64,3 +64,15 @@ class InvalidConfig(DashException):
6464

6565
class InvalidResourceError(DashException):
6666
pass
67+
68+
69+
class InvalidIndexException(DashException):
70+
pass
71+
72+
73+
class DependencyException(DashException):
74+
pass
75+
76+
77+
class ResourceException(DashException):
78+
pass

dash/resources.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import os
44

55
from .development.base_component import ComponentRegistry
6+
from . import exceptions
67

78

89
# pylint: disable=old-style-class
@@ -47,7 +48,7 @@ def _filter_resources(self, all_resources, dev_bundles=False):
4748
)
4849
continue
4950
else:
50-
raise Exception(
51+
raise exceptions.ResourceException(
5152
'{} does not have a '
5253
'relative_package_path, absolute_path, or an '
5354
'external_url.'.format(

dash/version.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
__version__ = '0.32.2'
1+
__version__ = '0.33.0'

0 commit comments

Comments
 (0)