|
@ -1,37 +1,35 @@ |
|
|
"""Errors in song definition (syntax errors, and so on)""" |
|
|
"""Errors in song definition (syntax errors, and so on)""" |
|
|
|
|
|
|
|
|
class SongError(Exception): |
|
|
from patacrep.errors import SharedError |
|
|
|
|
|
|
|
|
|
|
|
class SongError(SharedError): |
|
|
"""Generic song error""" |
|
|
"""Generic song error""" |
|
|
# pylint: disable=too-few-public-methods |
|
|
# pylint: disable=too-few-public-methods |
|
|
|
|
|
|
|
|
type = "generic" |
|
|
def __init__(self, song, message): |
|
|
|
|
|
|
|
|
def __init__(self, message): |
|
|
|
|
|
super().__init__() |
|
|
super().__init__() |
|
|
|
|
|
self.song = song |
|
|
self.message = message |
|
|
self.message = message |
|
|
|
|
|
|
|
|
def __str__(self): |
|
|
def __str__(self): |
|
|
raise NotImplementedError() |
|
|
return "Song {}: {}".format(self.song, self.message) |
|
|
|
|
|
|
|
|
class SongSyntaxError(SongError): |
|
|
class SongSyntaxError(SongError): |
|
|
"""Syntax error""" |
|
|
"""Syntax error""" |
|
|
# pylint: disable=too-few-public-methods |
|
|
# pylint: disable=too-few-public-methods |
|
|
|
|
|
|
|
|
type = "syntax" |
|
|
def __init__(self, song, line, message): |
|
|
|
|
|
super().__init__(song, message) |
|
|
def __init__(self, line, message): |
|
|
|
|
|
super().__init__(message) |
|
|
|
|
|
#: Line of error. May be `None` if irrelevant. |
|
|
#: Line of error. May be `None` if irrelevant. |
|
|
self.line = line |
|
|
self.line = line |
|
|
|
|
|
|
|
|
def __str__(self): |
|
|
def __str__(self): |
|
|
if self.line is not None: |
|
|
if self.line is not None: |
|
|
return "Line {}: {}".format(self.line, self.message) |
|
|
return "Song {}, line {}: {}".format(self.song, self.line, self.message) |
|
|
else: |
|
|
else: |
|
|
return self.message |
|
|
return "Song {}: {}".format(self.song, self.message) |
|
|
|
|
|
|
|
|
# class FileError(SongError): |
|
|
# class FileError(SongError): |
|
|
# type = "file" |
|
|
# type = "file" |
|
|
# |
|
|
# |
|
|
# class LanguageError(SongError): |
|
|
# class LanguageError(SongError): |
|
|
# type = "language" |
|
|
|
|
|