From 6933512334ba84c4dd44e8c55eb83dce7353b8ac Mon Sep 17 00:00:00 2001 From: Shammamah Hossain Date: Mon, 10 Dec 2018 10:47:56 -0500 Subject: [PATCH 1/6] Create and implement new exception types. --- dash/dash.py | 10 +++++----- dash/exceptions.py | 6 ++++++ dash/resources.py | 4 ++-- 3 files changed, 13 insertions(+), 7 deletions(-) diff --git a/dash/dash.py b/dash/dash.py index 3beb789871..29d4d9a94c 100644 --- a/dash/dash.py +++ b/dash/dash.py @@ -275,7 +275,7 @@ def _layout_value(self): def layout(self, value): if (not isinstance(value, Component) and not isinstance(value, collections.Callable)): - raise Exception( + raise exceptions.NoLayoutException( '' 'Layout must be a dash component ' 'or a function that returns ' @@ -301,7 +301,7 @@ def index_string(self, value): ) missing = [missing for check, missing in checks if not check] if missing: - raise Exception( + raise exceptions.InvalidIndexException( 'Did you forget to include {} in your index string ?'.format( ', '.join('{%' + x + '%}' for x in missing) ) @@ -472,14 +472,14 @@ def _generate_meta_html(self): # Serve the JS bundles for each package def serve_component_suites(self, package_name, path_in_package_dist): if package_name not in self.registered_paths: - raise exceptions.InvalidResourceError( + raise exceptions.DependencyException( 'Error loading dependency.\n' '"{}" is not a registered library.\n' 'Registered libraries are: {}' .format(package_name, list(self.registered_paths.keys()))) elif path_in_package_dist not in self.registered_paths[package_name]: - raise exceptions.InvalidResourceError( + raise exceptions.DependencyException( '"{}" is registered but the path requested is not valid.\n' 'The path requested: "{}"\n' 'List of registered paths: {}' @@ -542,7 +542,7 @@ def index(self, *args, **kwargs): # pylint: disable=unused-argument if missing: plural = 's' if len(missing) > 1 else '' - raise Exception( + raise exceptions.InvalidIndexException( 'Missing element{pl} {ids} in index.'.format( ids=', '.join(missing), pl=plural diff --git a/dash/exceptions.py b/dash/exceptions.py index 5ec2779afb..b87703249d 100644 --- a/dash/exceptions.py +++ b/dash/exceptions.py @@ -64,3 +64,9 @@ class InvalidConfig(DashException): class InvalidResourceError(DashException): pass + +class InvalidIndexException(DashException): + pass + +class DependencyException(DashException): + pass diff --git a/dash/resources.py b/dash/resources.py index 603bd37afe..15d173e61e 100644 --- a/dash/resources.py +++ b/dash/resources.py @@ -3,7 +3,7 @@ import os from .development.base_component import ComponentRegistry - +from . import exceptions # pylint: disable=old-style-class class Resources: @@ -45,7 +45,7 @@ def _filter_resources(self, all_resources, dev_bundles=False): ) continue else: - raise Exception( + raise exceptions.ResourceException( '{} does not have a ' 'relative_package_path, absolute_path, or an ' 'external_url.'.format( From 2e7533ec86ecdbe9d60c40fd882948e09c046027 Mon Sep 17 00:00:00 2001 From: Shammamah Hossain Date: Mon, 10 Dec 2018 15:54:02 -0500 Subject: [PATCH 2/6] Add ResourceException. --- dash/exceptions.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/dash/exceptions.py b/dash/exceptions.py index b87703249d..5d90704a0e 100644 --- a/dash/exceptions.py +++ b/dash/exceptions.py @@ -65,8 +65,14 @@ class InvalidConfig(DashException): class InvalidResourceError(DashException): pass + class InvalidIndexException(DashException): pass + class DependencyException(DashException): pass + + +class ResourceException(DashException): + pass From ca2d281166fb6c6edae1fa366ff5035a0fe9f6ac Mon Sep 17 00:00:00 2001 From: Shammamah Hossain Date: Mon, 10 Dec 2018 15:56:35 -0500 Subject: [PATCH 3/6] Fix whitespace issue. --- dash/resources.py | 1 + 1 file changed, 1 insertion(+) diff --git a/dash/resources.py b/dash/resources.py index 302ab06f99..ac19f640c4 100644 --- a/dash/resources.py +++ b/dash/resources.py @@ -5,6 +5,7 @@ from .development.base_component import ComponentRegistry from . import exceptions + # pylint: disable=old-style-class class Resources: def __init__(self, resource_name, layout): From 5ee1929ac9a5dc706284d7b9dad57fa1cf5415e1 Mon Sep 17 00:00:00 2001 From: Shammamah Hossain Date: Mon, 10 Dec 2018 16:06:26 -0500 Subject: [PATCH 4/6] Update changelog and version number. --- CHANGELOG.md | 4 ++++ dash/version.py | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index d76e8a10ac..45f3e7ca68 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,7 @@ +## 0.32.3 - 2018-12-10 +## Changed +- Added specific Dash exception types to replace generic exceptions [#487](https://github.com/plotly/dash/pull/487) + ## 0.32.2 - 2018-12-09 ## Fixed - Fix typo in missing events/inputs error message [#485](https://github.com/plotly/dash/pull/485) diff --git a/dash/version.py b/dash/version.py index 03de7de689..fb0ef16c12 100644 --- a/dash/version.py +++ b/dash/version.py @@ -1 +1 @@ -__version__ = '0.32.2' +__version__ = '0.32.3' From 526c580d60cd4dd68b9b1f846436322098758183 Mon Sep 17 00:00:00 2001 From: Shammamah Hossain Date: Mon, 10 Dec 2018 16:29:15 -0500 Subject: [PATCH 5/6] Add specific new exception types to changelog and change back version number. --- CHANGELOG.md | 4 ++-- dash/version.py | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 45f3e7ca68..e47f3d59d7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,6 @@ ## 0.32.3 - 2018-12-10 -## Changed -- Added specific Dash exception types to replace generic exceptions [#487](https://github.com/plotly/dash/pull/487) +## Added +- Added specific Dash exception types to replace generic exceptions (InvalidIndexException, DependencyException, ResourceException) [#487](https://github.com/plotly/dash/pull/487) ## 0.32.2 - 2018-12-09 ## Fixed diff --git a/dash/version.py b/dash/version.py index fb0ef16c12..03de7de689 100644 --- a/dash/version.py +++ b/dash/version.py @@ -1 +1 @@ -__version__ = '0.32.3' +__version__ = '0.32.2' From 3a693776adc44ec4fcffddf443c263536854a3a6 Mon Sep 17 00:00:00 2001 From: Shammamah Hossain Date: Tue, 11 Dec 2018 12:10:29 -0500 Subject: [PATCH 6/6] Change version number. --- CHANGELOG.md | 2 +- dash/version.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index e47f3d59d7..e9409006d8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,4 +1,4 @@ -## 0.32.3 - 2018-12-10 +## 0.33.0 - 2018-12-10 ## Added - Added specific Dash exception types to replace generic exceptions (InvalidIndexException, DependencyException, ResourceException) [#487](https://github.com/plotly/dash/pull/487) diff --git a/dash/version.py b/dash/version.py index 03de7de689..e3d0b7be11 100644 --- a/dash/version.py +++ b/dash/version.py @@ -1 +1 @@ -__version__ = '0.32.2' +__version__ = '0.33.0'