diff options
author | Mike Bayer <mike_mp@zzzcomputing.com> | 2020-06-11 14:31:57 -0400 |
---|---|---|
committer | Mike Bayer <mike_mp@zzzcomputing.com> | 2020-06-11 14:31:57 -0400 |
commit | dbaf82d258cc12d92ef28de4677d147fdb7808fd (patch) | |
tree | e4239cbf2d6c9265ab28a2db1fb5844b114e3e49 /lib | |
parent | ed4a4896aea7dd77dd5d8a9861302811ac421e47 (diff) | |
download | sqlalchemy-dbaf82d258cc12d92ef28de4677d147fdb7808fd.tar.gz |
Add version token to error URL
the sqlalche.me redirector now supports the numerical version
code in the URL, e.g. /13/, /14/, /20/, etc., so that we can
redirect to the error codes for the appropriate version
of SQLAlchemy in use without going through the catch-all "latest"
link. If a particular version of the docs is no longer on the
site, the redirect will revert to falling through the "latest"
link (which ultimately lands on the current release version,
/13/ at the time of this writing).
Change-Id: I3bb463fd6fb6c8767c95a57f3699aba715a9a72d
Diffstat (limited to 'lib')
-rw-r--r-- | lib/sqlalchemy/__init__.py | 4 | ||||
-rw-r--r-- | lib/sqlalchemy/exc.py | 4 |
2 files changed, 7 insertions, 1 deletions
diff --git a/lib/sqlalchemy/__init__.py b/lib/sqlalchemy/__init__.py index 27e9fd1c0..d52393d0b 100644 --- a/lib/sqlalchemy/__init__.py +++ b/lib/sqlalchemy/__init__.py @@ -142,5 +142,9 @@ def __go(lcls): _sa_util.preloaded.import_prefix("sqlalchemy") + from . import exc + + exc._version_token = "".join(__version__.split(".")[0:2]) + __go(locals()) diff --git a/lib/sqlalchemy/exc.py b/lib/sqlalchemy/exc.py index 92322fb90..491dde7b2 100644 --- a/lib/sqlalchemy/exc.py +++ b/lib/sqlalchemy/exc.py @@ -15,6 +15,8 @@ raised as a result of DBAPI exceptions are all subclasses of from .util import compat +_version_token = None + class SQLAlchemyError(Exception): """Generic error class.""" @@ -33,7 +35,7 @@ class SQLAlchemyError(Exception): else: return ( "(Background on this error at: " - "http://sqlalche.me/e/%s)" % (self.code,) + "http://sqlalche.me/e/%s/%s)" % (_version_token, self.code,) ) def _message(self, as_unicode=compat.py3k): |