-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathexception.py
58 lines (44 loc) · 1.87 KB
/
exception.py
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
# -*- coding: utf-8 -*-
# This file is part of the pymfony package.
#
# (c) Alexandre Quercia <[email protected]>
#
# For the full copyright and license information, please view the LICENSE
# file that was distributed with this source code.
from __future__ import absolute_import;
from pymfony.component.system.exception import StandardException;
"""
"""
class FileLoaderLoadException(StandardException):
"""Exception class for when a resource cannot be loaded or imported.
@author Ryan Weaver <[email protected]>
"""
def __init__(self, resource, sourceResource=None, code=0, previous=None):
if sourceResource is None:
message = 'Cannot load resource "{0}".'.format(repr(resource));
else:
message = 'Cannot import resource "{0}" from "{1}".'.format(
repr(resource), repr(sourceResource)
);
# Is the resource located inside a bundle?
if resource.startswith('@'):
bundle = str(resource)[1:].split('/', 1)[0];
message += (' Make sure the "{0}" bundle is correctly registered '
'and loaded in the application kernel class.'
''.format(bundle)
);
StandardException.__init__(self, message, code, previous);
class FileLoaderImportCircularReferenceException(FileLoaderLoadException):
"""Exception class for when a circular reference is detected when
importing resources.
@author Fabien Potencier <[email protected]>
"""
def __init__(self, resources, code=None, previous=None):
"""
@param resources: list
"""
assert isinstance(resources, list);
message = ('Circular reference detected in "{0}" ("{1}" > "{2}").'
''.format(repr(resources[0]), " > ".join(resources), repr(resources[0])
));
StandardException.__init__(self, message, code, previous);