Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
sagemath
GitHub Repository: sagemath/sagelib
Path: blob/master/sage/misc/exceptions.py
4036 views
1
r"""
2
Exceptions
3
4
This module defines Sage-specific exceptions.
5
"""
6
7
class OptionalPackageNotFoundError(RuntimeError):
8
"""
9
This class defines the exception that should be raised when a
10
function, method, or class cannot detect an optional package that
11
it depends on. When an ``OptionalPackageNotFoundError`` is
12
raised, this means one of the following:
13
14
- The required optional package is not installed.
15
16
- The required optional package is installed, but the relevant
17
interface to that package is unable to detect the package.
18
19
EXAMPLES::
20
21
sage: from sage.misc.exceptions import OptionalPackageNotFoundError
22
sage: def find_package(fav_package):
23
... try:
24
... raise OptionalPackageNotFoundError("Unable to detect optional package: %s" % fav_package)
25
... except OptionalPackageNotFoundError:
26
... raise
27
...
28
sage: find_package("ham and spam")
29
Traceback (most recent call last):
30
...
31
OptionalPackageNotFoundError: Unable to detect optional package: ham and spam
32
"""
33
pass
34
35