mapbox / tilesets-cli

CLI for interacting with the Mapbox Tilesets API and Mapbox Tiling Service
https://docs.mapbox.com/mapbox-tiling-service
BSD 2-Clause "Simplified" License
125 stars 27 forks source link

TilesetNameError message includes both tileset id and description #72

Closed dianeschulze closed 4 years ago

dianeschulze commented 4 years ago

TilesetNameError is intended to log a message like {tileset_id} is not a valid Tileset ID, but it actually only logs the tileset ID.

This PR defines the __str__() function on TilesetNameError so the message can include both the tileset ID and the description.

Before:

$ tilesets create invalid -r recipe.json -n "invalid id"
Traceback (most recent call last):
  File "/Users/dianeschulze/.virtualenvs/tilesets-cli/bin/tilesets", line 11, in <module>
    load_entry_point('mapbox-tilesets', 'console_scripts', 'tilesets')()
  File "/Users/dianeschulze/.virtualenvs/tilesets-cli/lib/python3.7/site-packages/click/core.py", line 764, in __call__
    return self.main(*args, **kwargs)
  File "/Users/dianeschulze/.virtualenvs/tilesets-cli/lib/python3.7/site-packages/click/core.py", line 717, in main
    rv = self.invoke(ctx)
  File "/Users/dianeschulze/.virtualenvs/tilesets-cli/lib/python3.7/site-packages/click/core.py", line 1137, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/Users/dianeschulze/.virtualenvs/tilesets-cli/lib/python3.7/site-packages/click/core.py", line 956, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/Users/dianeschulze/.virtualenvs/tilesets-cli/lib/python3.7/site-packages/click/core.py", line 555, in invoke
    return callback(*args, **kwargs)
  File "/Users/dianeschulze/work/mapbox/tilesets-cli/mapbox_tilesets/scripts/cli.py", line 108, in create
    raise errors.TilesetNameError(tileset)
mapbox_tilesets.errors.TilesetNameError: invalid

After:

$ tilesets create invalid -r recipe.json -n "invalid id"
Traceback (most recent call last):
  File "/Users/dianeschulze/.virtualenvs/tilesets-cli/bin/tilesets", line 11, in <module>
    load_entry_point('mapbox-tilesets', 'console_scripts', 'tilesets')()
  File "/Users/dianeschulze/.virtualenvs/tilesets-cli/lib/python3.7/site-packages/click/core.py", line 764, in __call__
    return self.main(*args, **kwargs)
  File "/Users/dianeschulze/.virtualenvs/tilesets-cli/lib/python3.7/site-packages/click/core.py", line 717, in main
    rv = self.invoke(ctx)
  File "/Users/dianeschulze/.virtualenvs/tilesets-cli/lib/python3.7/site-packages/click/core.py", line 1137, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/Users/dianeschulze/.virtualenvs/tilesets-cli/lib/python3.7/site-packages/click/core.py", line 956, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/Users/dianeschulze/.virtualenvs/tilesets-cli/lib/python3.7/site-packages/click/core.py", line 555, in invoke
    return callback(*args, **kwargs)
  File "/Users/dianeschulze/work/mapbox/tilesets-cli/mapbox_tilesets/scripts/cli.py", line 108, in create
    raise errors.TilesetNameError(tileset)
mapbox_tilesets.errors.TilesetNameError: invalid -> Invalid Tileset ID

TODO: