summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authoralalazo <massimiliano.culpo@googlemail.com>2016-10-23 13:34:29 +0200
committeralalazo <massimiliano.culpo@googlemail.com>2016-10-23 13:34:29 +0200
commit284ed13fa658f90226f6b26bc4f0529722401992 (patch)
tree1cf8398eeaa17e2c2ad58b7fdf74362c096cd1a3 /lib
parentbdf48322696290d4e3d00ed12b7c7fe6ca213478 (diff)
downloadspack-284ed13fa658f90226f6b26bc4f0529722401992.tar.gz
spack-284ed13fa658f90226f6b26bc4f0529722401992.tar.bz2
spack-284ed13fa658f90226f6b26bc4f0529722401992.tar.xz
spack-284ed13fa658f90226f6b26bc4f0529722401992.zip
spack.error : fixed pickling and representation to permit to pass FetchErrors
Diffstat (limited to 'lib')
-rw-r--r--lib/spack/spack/error.py13
1 files changed, 12 insertions, 1 deletions
diff --git a/lib/spack/spack/error.py b/lib/spack/spack/error.py
index c94875e91a..5e5c1b1c7e 100644
--- a/lib/spack/spack/error.py
+++ b/lib/spack/spack/error.py
@@ -26,6 +26,7 @@ import os
import sys
import llnl.util.tty as tty
import spack
+import inspect
class SpackError(Exception):
@@ -49,7 +50,7 @@ class SpackError(Exception):
else:
tty.error(self.message)
if self.long_message:
- print self.long_message
+ print(self.long_message)
os._exit(1)
def __str__(self):
@@ -58,6 +59,16 @@ class SpackError(Exception):
msg += "\n %s" % self._long_message
return msg
+ def __repr__(self):
+ args = [repr(self.message), repr(self.long_message)]
+ args = ','.join(args)
+ qualified_name = inspect.getmodule(
+ self).__name__ + '.' + type(self).__name__
+ return qualified_name + '(' + args + ')'
+
+ def __reduce__(self):
+ return type(self), (self.message, self.long_message)
+
class UnsupportedPlatformError(SpackError):
"""Raised by packages when a platform is not supported"""