Derive all exceptions correctly from base exceptions

Don't need to define __init__ and manually call the parent init. Doing
so messes up the error message you get by doing str(exception) because
it includes the current class name in it repeatedly.
pull/1312/head
Nirbheek Chauhan 8 years ago
parent 11f9425a5e
commit e441a74282
  1. 8
      mesonbuild/dependencies.py
  2. 6
      mesonbuild/mesonlib.py

@ -30,8 +30,7 @@ from . import mesonlib
from .environment import detect_cpu_family, for_windows
class DependencyException(MesonException):
def __init__(self, *args, **kwargs):
MesonException.__init__(self, *args, **kwargs)
'''Exceptions raised while trying to find dependencies'''
class Dependency():
def __init__(self, type_name='unknown'):
@ -170,9 +169,8 @@ class PkgConfigDependency(Dependency):
if not self.silent:
mlog.log(*found_msg)
if self.required:
raise DependencyException(
'Invalid version of a dependency, needed %s %s found %s.' %
(name, not_found, self.modversion))
m = 'Invalid version of dependency, need {!r} {!r} found {!r}.'
raise DependencyException(m.format(name, not_found, self.modversion))
return
found_msg += [mlog.green('YES'), self.modversion]
if not self.silent:

@ -19,12 +19,10 @@ import platform, subprocess, operator, os, shutil, re
from glob import glob
class MesonException(Exception):
def __init__(self, *args, **kwargs):
Exception.__init__(self, *args, **kwargs)
'''Exceptions thrown by Meson'''
class EnvironmentException(MesonException):
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
'''Exceptions thrown while processing and creating the build environment'''
class File:
def __init__(self, is_built, subdir, fname):

Loading…
Cancel
Save