File: errors.py

package info (click to toggle)
mozjs78 78.15.0-7
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 739,892 kB
  • sloc: javascript: 1,344,214; cpp: 1,215,708; python: 526,544; ansic: 433,835; xml: 118,736; sh: 26,176; asm: 16,664; makefile: 11,537; yacc: 4,486; perl: 2,564; ada: 1,681; lex: 1,414; pascal: 1,139; cs: 879; exp: 499; java: 164; ruby: 68; sql: 45; csh: 35; sed: 18; lisp: 2
file content (70 lines) | stat: -rw-r--r-- 2,579 bytes parent folder | download | duplicates (11)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
from __future__ import unicode_literals


class ParseError(Exception):
    def __init__(self, code, *args):
        self.code = code
        self.args = args
        self.message = get_error_message(code, args)


def get_error_message(code, args):
    if code == 'E00001':
        return 'Generic error'
    if code == 'E0002':
        return 'Expected an entry start'
    if code == 'E0003':
        return 'Expected token: "{}"'.format(args[0])
    if code == 'E0004':
        return 'Expected a character from range: "{}"'.format(args[0])
    if code == 'E0005':
        msg = 'Expected message "{}" to have a value or attributes'
        return msg.format(args[0])
    if code == 'E0006':
        msg = 'Expected term "-{}" to have a value'
        return msg.format(args[0])
    if code == 'E0007':
        return 'Keyword cannot end with a whitespace'
    if code == 'E0008':
        return 'The callee has to be an upper-case identifier or a term'
    if code == 'E0009':
        return 'The argument name has to be a simple identifier'
    if code == 'E0010':
        return 'Expected one of the variants to be marked as default (*)'
    if code == 'E0011':
        return 'Expected at least one variant after "->"'
    if code == 'E0012':
        return 'Expected value'
    if code == 'E0013':
        return 'Expected variant key'
    if code == 'E0014':
        return 'Expected literal'
    if code == 'E0015':
        return 'Only one variant can be marked as default (*)'
    if code == 'E0016':
        return 'Message references cannot be used as selectors'
    if code == 'E0017':
        return 'Terms cannot be used as selectors'
    if code == 'E0018':
        return 'Attributes of messages cannot be used as selectors'
    if code == 'E0019':
        return 'Attributes of terms cannot be used as placeables'
    if code == 'E0020':
        return 'Unterminated string expression'
    if code == 'E0021':
        return 'Positional arguments must not follow named arguments'
    if code == 'E0022':
        return 'Named arguments must be unique'
    if code == 'E0024':
        return 'Cannot access variants of a message.'
    if code == 'E0025':
        return 'Unknown escape sequence: \\{}.'.format(args[0])
    if code == 'E0026':
        return 'Invalid Unicode escape sequence: {}.'.format(args[0])
    if code == 'E0027':
        return 'Unbalanced closing brace in TextElement.'
    if code == 'E0028':
        return 'Expected an inline expression'
    if code == 'E0029':
        return 'Expected simple expression as selector'
    return code