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