Fix exception causes all over the codebase
This commit is contained in:
@@ -1189,8 +1189,8 @@ class Config:
|
||||
def _getini(self, name: str) -> Any:
|
||||
try:
|
||||
description, type, default = self._parser._inidict[name]
|
||||
except KeyError:
|
||||
raise ValueError("unknown configuration value: {!r}".format(name))
|
||||
except KeyError as e:
|
||||
raise ValueError("unknown configuration value: {!r}".format(name)) from e
|
||||
override_value = self._get_override_ini_value(name)
|
||||
if override_value is None:
|
||||
try:
|
||||
@@ -1286,14 +1286,14 @@ class Config:
|
||||
if val is None and skip:
|
||||
raise AttributeError(name)
|
||||
return val
|
||||
except AttributeError:
|
||||
except AttributeError as e:
|
||||
if default is not notset:
|
||||
return default
|
||||
if skip:
|
||||
import pytest
|
||||
|
||||
pytest.skip("no {!r} option found".format(name))
|
||||
raise ValueError("no option named {!r}".format(name))
|
||||
raise ValueError("no option named {!r}".format(name)) from e
|
||||
|
||||
def getvalue(self, name, path=None):
|
||||
""" (deprecated, use getoption()) """
|
||||
|
||||
@@ -265,9 +265,9 @@ class Argument:
|
||||
else:
|
||||
try:
|
||||
self.dest = self._short_opts[0][1:]
|
||||
except IndexError:
|
||||
except IndexError as e:
|
||||
self.dest = "???" # Needed for the error repr.
|
||||
raise ArgumentError("need a long or short option", self)
|
||||
raise ArgumentError("need a long or short option", self) from e
|
||||
|
||||
def names(self) -> List[str]:
|
||||
return self._short_opts + self._long_opts
|
||||
|
||||
@@ -26,7 +26,7 @@ def _parse_ini_config(path: py.path.local) -> iniconfig.IniConfig:
|
||||
try:
|
||||
return iniconfig.IniConfig(path)
|
||||
except iniconfig.ParseError as exc:
|
||||
raise UsageError(str(exc))
|
||||
raise UsageError(str(exc)) from exc
|
||||
|
||||
|
||||
def load_config_dict_from_file(
|
||||
|
||||
Reference in New Issue
Block a user