mirror of
https://github.com/beetbox/beets.git
synced 2025-12-24 09:33:46 +01:00
better error message when using real tabs
This commit is contained in:
parent
887d1c1287
commit
2ea190ceba
3 changed files with 18 additions and 3 deletions
|
|
@ -36,6 +36,8 @@ CONFIG_FILENAME = 'config.yaml'
|
|||
DEFAULT_FILENAME = 'config_default.yaml'
|
||||
ROOT_NAME = 'root'
|
||||
|
||||
YAML_TAB_PROBLEM = "found character '\\t' that cannot start any token"
|
||||
|
||||
|
||||
# Utilities.
|
||||
|
||||
|
|
@ -81,9 +83,19 @@ class ConfigReadError(ConfigError):
|
|||
def __init__(self, filename, reason=None):
|
||||
self.filename = filename
|
||||
self.reason = reason
|
||||
|
||||
message = 'file {0} could not be read'.format(filename)
|
||||
if reason:
|
||||
if isinstance(reason, yaml.scanner.ScannerError) and \
|
||||
reason.problem == YAML_TAB_PROBLEM:
|
||||
# Special-case error message for tab indentation in YAML markup.
|
||||
message += ': found tab character at line {0}, column {1}'.format(
|
||||
reason.problem_mark.line + 1,
|
||||
reason.problem_mark.column + 1,
|
||||
)
|
||||
elif reason:
|
||||
# Generic error message uses exception's message.
|
||||
message += ': {0}'.format(reason)
|
||||
|
||||
super(ConfigReadError, self).__init__(message)
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -35,6 +35,8 @@ Other new stuff:
|
|||
* :doc:`/plugins/mpdupdate`: Sends an update message whenever *anything* in the
|
||||
database changes---not just when importing. Thanks to Dang Mai Hai.
|
||||
* Fix an error when migrating the ``.beetsstate`` file on Windows.
|
||||
* A nicer error message is now given when the configuration file contains tabs.
|
||||
(YAML doesn't like tabs.)
|
||||
|
||||
1.1b1 (January 29, 2013)
|
||||
------------------------
|
||||
|
|
|
|||
|
|
@ -23,8 +23,9 @@ file will look like this::
|
|||
key: value
|
||||
foo: bar
|
||||
|
||||
If you have questions about more sophisticated syntax, take a look at the
|
||||
`YAML`_ documentation.
|
||||
In YAML, you will need to use spaces (not tabs!) to indent some lines. If you
|
||||
have questions about more sophisticated syntax, take a look at the `YAML`_
|
||||
documentation.
|
||||
|
||||
.. _YAML: http://yaml.org/
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue