Method: flask.app.Flask.handle_url_build_error
Calls: 6, Exceptions: 2, Paths: 4Back
Path 1: 2 calls (0.33)
BuildError (2)
'spam' (2)
{'_anchor': None, '_method': None, '_scheme': None, '_external': False} (2)
1def handle_url_build_error(
2 self, error: BuildError, endpoint: str, values: dict[str, t.Any]
3 ) -> str:
4 """Called by :meth:`.url_for` if a
5 :exc:`~werkzeug.routing.BuildError` was raised. If this returns
6 a value, it will be returned by ``url_for``, otherwise the error
7 will be re-raised.
8
9 Each function in :attr:`url_build_error_handlers` is called with
10 ``error``, ``endpoint`` and ``values``. If a function returns
11 ``None`` or raises a ``BuildError``, it is skipped. Otherwise,
12 its return value is returned by ``url_for``.
13
14 :param error: The active ``BuildError`` being handled.
15 :param endpoint: The endpoint being built.
16 :param values: The keyword arguments passed to ``url_for``.
17 """
18 for handler in self.url_build_error_handlers:
19 try:
20 rv = handler(error, endpoint, values)
21 except BuildError as e:
22 # make error available outside except block
23 error = e
24 else:
25 if rv is not None:
26 return rv
27
28 # Re-raise if called with an active exception, otherwise raise
29 # the passed in exception.
30 if error is sys.exc_info()[1]:
31 raise
32
33 raise error
Path 2: 2 calls (0.33)
BuildError (2)
'spam' (1) '/' (1)
{'_anchor': None, '_method': None, '_scheme': None, '_external': False} (2)
'/test_handler/' (1) 'handled' (1)
1def handle_url_build_error(
2 self, error: BuildError, endpoint: str, values: dict[str, t.Any]
3 ) -> str:
4 """Called by :meth:`.url_for` if a
5 :exc:`~werkzeug.routing.BuildError` was raised. If this returns
6 a value, it will be returned by ``url_for``, otherwise the error
7 will be re-raised.
8
9 Each function in :attr:`url_build_error_handlers` is called with
10 ``error``, ``endpoint`` and ``values``. If a function returns
11 ``None`` or raises a ``BuildError``, it is skipped. Otherwise,
12 its return value is returned by ``url_for``.
13
14 :param error: The active ``BuildError`` being handled.
15 :param endpoint: The endpoint being built.
16 :param values: The keyword arguments passed to ``url_for``.
17 """
18 for handler in self.url_build_error_handlers:
19 try:
20 rv = handler(error, endpoint, values)
21 except BuildError as e:
22 # make error available outside except block
23 error = e
24 else:
25 if rv is not None:
26 return rv
27
28 # Re-raise if called with an active exception, otherwise raise
29 # the passed in exception.
30 if error is sys.exc_info()[1]:
31 raise
32
33 raise error
Path 3: 1 calls (0.17)
BuildError (1)
'spam' (1)
{} (1)
BuildError (1)
1def handle_url_build_error(
2 self, error: BuildError, endpoint: str, values: dict[str, t.Any]
3 ) -> str:
4 """Called by :meth:`.url_for` if a
5 :exc:`~werkzeug.routing.BuildError` was raised. If this returns
6 a value, it will be returned by ``url_for``, otherwise the error
7 will be re-raised.
8
9 Each function in :attr:`url_build_error_handlers` is called with
10 ``error``, ``endpoint`` and ``values``. If a function returns
11 ``None`` or raises a ``BuildError``, it is skipped. Otherwise,
12 its return value is returned by ``url_for``.
13
14 :param error: The active ``BuildError`` being handled.
15 :param endpoint: The endpoint being built.
16 :param values: The keyword arguments passed to ``url_for``.
17 """
18 for handler in self.url_build_error_handlers:
19 try:
20 rv = handler(error, endpoint, values)
21 except BuildError as e:
22 # make error available outside except block
23 error = e
24 else:
25 if rv is not None:
26 return rv
27
28 # Re-raise if called with an active exception, otherwise raise
29 # the passed in exception.
30 if error is sys.exc_info()[1]:
31 raise
32
33 raise error
Path 4: 1 calls (0.17)
BuildError (1)
'not.existing' (1)
{'_anchor': None, '_method': None, '_scheme': None, '_external': False} (1)
BuildError (1)
1def handle_url_build_error(
2 self, error: BuildError, endpoint: str, values: dict[str, t.Any]
3 ) -> str:
4 """Called by :meth:`.url_for` if a
5 :exc:`~werkzeug.routing.BuildError` was raised. If this returns
6 a value, it will be returned by ``url_for``, otherwise the error
7 will be re-raised.
8
9 Each function in :attr:`url_build_error_handlers` is called with
10 ``error``, ``endpoint`` and ``values``. If a function returns
11 ``None`` or raises a ``BuildError``, it is skipped. Otherwise,
12 its return value is returned by ``url_for``.
13
14 :param error: The active ``BuildError`` being handled.
15 :param endpoint: The endpoint being built.
16 :param values: The keyword arguments passed to ``url_for``.
17 """
18 for handler in self.url_build_error_handlers:
19 try:
20 rv = handler(error, endpoint, values)
21 except BuildError as e:
22 # make error available outside except block
23 error = e
24 else:
25 if rv is not None:
26 return rv
27
28 # Re-raise if called with an active exception, otherwise raise
29 # the passed in exception.
30 if error is sys.exc_info()[1]:
31 raise
32
33 raise error