Skip to content

Bare Exceptions #304

@T4rk1n

Description

@T4rk1n

Currently, there is a couple bare Exception that are raised by dash, they should be refactored into appropriate DashException.

Should be a TypeError or NoLayoutException:

dash/dash/dash.py

Lines 197 to 203 in 54ca4a3

if (not isinstance(value, Component) and
not isinstance(value, collections.Callable)):
raise Exception(
''
'Layout must be a dash component '
'or a function that returns '
'a dash component.')

A new exception type InvalidIndexException:

dash/dash/dash.py

Lines 224 to 229 in 54ca4a3

if missing:
raise Exception(
'Did you forget to include {} in your index string ?'.format(
', '.join('{%' + x + '%}' for x in missing)
)
)

dash/dash/dash.py

Lines 409 to 415 in 54ca4a3

plural = 's' if len(missing) > 1 else ''
raise Exception(
'Missing element{pl} {ids} in index.'.format(
ids=', '.join(missing),
pl=plural
)
)

A new exception type DependencyException:

dash/dash/dash.py

Lines 357 to 374 in 54ca4a3

if package_name not in self.registered_paths:
raise Exception(
'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 Exception(
'"{}" is registered but the path requested is not valid.\n'
'The path requested: "{}"\n'
'List of registered paths: {}'
.format(
package_name,
path_in_package_dist,
self.registered_paths
)
)

ResourceException ?:

dash/dash/resources.py

Lines 42 to 48 in 54ca4a3

raise Exception(
'{} does not have a '
'relative_package_path, absolute_path, or an '
'external_url.'.format(
json.dumps(filtered_resource)
)
)

Metadata

Metadata

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions