X-Git-Url: https://git.alrj.org/?p=bold.git;a=blobdiff_plain;f=Bold%2Ferrors.py;fp=Bold%2Ferrors.py;h=98db3e84b144b39f73b6a3b48822e4fac2fda234;hp=0000000000000000000000000000000000000000;hb=7eeaa837d3a6f29f9312bf29962214e709663e52;hpb=aa036795cb0ab7f31b9d78cfa562ccb603bc977a diff --git a/Bold/errors.py b/Bold/errors.py new file mode 100644 index 0000000..98db3e8 --- /dev/null +++ b/Bold/errors.py @@ -0,0 +1,49 @@ +# -*- coding: utf-8 -*- + +# kate: space-indent on; indent-width 2; mixedindent off; indent-mode python; + +# Copyright (C) 2009 Amand 'alrj' Tihon +# +# This file is part of bold, the Byte Optimized Linker. +# +# You can redistribute this file and/or modify it under the terms of the +# GNU Lesser General Public License as published by the Free Software +# Foundation, version 2.1. + +"""Define all the exceptions.""" + +class NotRelocatableObject(Exception): + """Raised when an input file is not a relocatable ELF object.""" + def __init__(self, path): + self.path = path + def __str__(self): + return "File '%s' is not a relocatable object file" % self.path + +class UnsupportedObject(Exception): + """Raised when an input file is not of a supported arch.""" + def __init__(self, path, reason): + self.path = path + self.reason = reason + def __str__(self): + return "File '%s' is not supported: %s" % (self.path, self.reason) + +class LibNotFound(Exception): + """Raised if a shared library could not be found.""" + def __init__(self, libname): + self.libname = libname + def __str__(self): + return "Cannot find shared library for '%s'" % self.libname + +class UndefinedSymbol(Exception): + """Raised if a symbol is referenced but not declared.""" + def __init__(self, symbol_name): + self.symbol = symbol_name + def __str__(self): + return "Undefined reference to '%s'" % self.symbol + +class RedefinedSymbol(Exception): + """Raised if a symbol is referenced but not declared.""" + def __init__(self, symbol_name): + self.symbol = symbol_name + def __str__(self): + return "Symbol '%s' is declared twice" % self.symbol