6565from easybuild .framework .easyconfig .templates import ALTERNATIVE_EASYCONFIG_TEMPLATES , DEPRECATED_EASYCONFIG_TEMPLATES
6666from easybuild .framework .easyconfig .templates import TEMPLATE_CONSTANTS , TEMPLATE_NAMES_DYNAMIC , template_constant_dict
6767from easybuild .tools import LooseVersion
68- from easybuild .tools .build_log import EasyBuildError , print_warning , print_msg
68+ from easybuild .tools .build_log import EasyBuildError , EasyBuildExit , print_warning , print_msg
6969from easybuild .tools .config import GENERIC_EASYBLOCK_PKG , LOCAL_VAR_NAMING_CHECK_ERROR , LOCAL_VAR_NAMING_CHECK_LOG
7070from easybuild .tools .config import LOCAL_VAR_NAMING_CHECK_WARN
7171from easybuild .tools .config import Singleton , build_option , get_module_naming_scheme
@@ -907,9 +907,12 @@ def validate_os_deps(self):
907907 not_found .append (dep )
908908
909909 if not_found :
910- raise EasyBuildError ("One or more OS dependencies were not found: %s" , not_found )
911- else :
912- self .log .info ("OS dependencies ok: %s" % self ['osdependencies' ])
910+ raise EasyBuildError (
911+ "One or more OS dependencies were not found: %s" , not_found ,
912+ exit_code = EasyBuildExit .MISSING_SYSTEM_DEPENDENCY
913+ )
914+
915+ self .log .info ("OS dependencies ok: %s" % self ['osdependencies' ])
913916
914917 return True
915918
@@ -1272,7 +1275,10 @@ def _validate(self, attr, values): # private method
12721275 if values is None :
12731276 values = []
12741277 if self [attr ] and self [attr ] not in values :
1275- raise EasyBuildError ("%s provided '%s' is not valid: %s" , attr , self [attr ], values )
1278+ raise EasyBuildError (
1279+ "%s provided '%s' is not valid: %s" , attr , self [attr ], values ,
1280+ exit_code = EasyBuildExit .VALUE_ERROR
1281+ )
12761282
12771283 def probe_external_module_metadata (self , mod_name , existing_metadata = None ):
12781284 """
@@ -1922,12 +1928,20 @@ def get_easyblock_class(easyblock, name=None, error_on_failed_import=True, error
19221928 error_re = re .compile (r"No module named '?.*/?%s'?" % modname )
19231929 _log .debug ("error regexp for ImportError on '%s' easyblock: %s" , modname , error_re .pattern )
19241930 if error_re .match (str (err )):
1931+ # Missing easyblock type of error
19251932 if error_on_missing_easyblock :
1926- raise EasyBuildError ("No software-specific easyblock '%s' found for %s" , class_name , name )
1927- elif error_on_failed_import :
1928- raise EasyBuildError ("Failed to import %s easyblock: %s" , class_name , err )
1933+ raise EasyBuildError (
1934+ "No software-specific easyblock '%s' found for %s" , class_name , name ,
1935+ exit_code = EasyBuildExit .MISSING_EASYBLOCK
1936+ ) from err
19291937 else :
1930- _log .debug ("Failed to import easyblock for %s, but ignoring it: %s" % (class_name , err ))
1938+ # Broken import
1939+ if error_on_failed_import :
1940+ raise EasyBuildError (
1941+ "Failed to import %s easyblock: %s" , class_name , err ,
1942+ exit_code = EasyBuildExit .EASYBLOCK_ERROR
1943+ ) from err
1944+ _log .debug ("Failed to import easyblock for %s, but ignoring it: %s" % (class_name , err ))
19311945
19321946 if cls is not None :
19331947 _log .info ("Successfully obtained class '%s' for easyblock '%s' (software name '%s')" ,
@@ -1941,7 +1955,10 @@ def get_easyblock_class(easyblock, name=None, error_on_failed_import=True, error
19411955 # simply reraise rather than wrapping it into another error
19421956 raise err
19431957 except Exception as err :
1944- raise EasyBuildError ("Failed to obtain class for %s easyblock (not available?): %s" , easyblock , err )
1958+ raise EasyBuildError (
1959+ "Failed to obtain class for %s easyblock (not available?): %s" , easyblock , err ,
1960+ exit_code = EasyBuildExit .EASYBLOCK_ERROR
1961+ )
19451962
19461963
19471964def get_module_path (name , generic = None , decode = True ):
@@ -2086,7 +2103,11 @@ def process_easyconfig(path, build_specs=None, validate=True, parse_only=False,
20862103 try :
20872104 ec = EasyConfig (spec , build_specs = build_specs , validate = validate , hidden = hidden )
20882105 except EasyBuildError as err :
2089- raise EasyBuildError ("Failed to process easyconfig %s: %s" , spec , err .msg )
2106+ try :
2107+ exit_code = err .exit_code
2108+ except AttributeError :
2109+ exit_code = EasyBuildExit .EASYCONFIG_ERROR
2110+ raise EasyBuildError ("Failed to process easyconfig %s: %s" , spec , err .msg , exit_code = exit_code )
20902111
20912112 name = ec ['name' ]
20922113
0 commit comments