Blame view

fsabuilder/morfeuszbuilder/utils/exceptions.py 953 Bytes
Michał Lenart authored
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
'''
Created on Feb 19, 2014

@author: lennyn
'''

class FSABuilderException(Exception):
    '''
    Exception in configFile module
    '''

    def __init__(self, msg):
        self.msg = msg

    def __str__(self):
Michał Lenart authored
16
        return 'Failed to create Morfeusz files: ' + self.msg
Michał Lenart authored
17
Michał Lenart authored
18
19
20
21
def validate(predicate, msg):
    if not predicate:
        raise FSABuilderException(msg)
Michał Lenart authored
22
23
24
25
26
27
class SegtypesException(FSABuilderException):

    def __init__(self, msg):
        self.msg = msg

    def __str__(self):
Marcin Woliński authored
28
        return 'Error in segment rules: %s' % self.msg
Michał Lenart authored
29
30
31
32
33
34
35
36
37

class ConfigFileException(FSABuilderException):

    def __init__(self, filename, lineNum, msg):
        self.filename = filename
        self.lineNum = lineNum
        self.msg = msg

    def __str__(self):
Michał Lenart authored
38
        if self.lineNum:
Marcin Woliński authored
39
            return '%s:%d - %s' % (self.filename, self.lineNum, self.msg)
Michał Lenart authored
40
        else:
Marcin Woliński authored
41
            return '%s - %s' % (self.filename, self.msg)
Michał Lenart authored
42