DErrno

mod:DErrno

synopsis:Error list and utilities for handling errors in DIRAC

This module contains list of errors that can be encountered in DIRAC. It complements the errno module of python.

It also contains utilities to manipulate these errors.

Finally, it contains a DErrno class that contains an error number as well as a low level error message. It behaves like a string for compatibility reasons

In order to add extension specific error, you need to create in your extension the file Core/Utilities/DErrno.py, which will contain the following dictionary:

  • extra_dErrName: keys are the error name, values the number of it
  • extra_dErrorCode: same as dErrorCode. keys are the error code, values the name
    (we don’t simply revert the previous dict in case we do not have a one to one mapping)
  • extra_dStrError: same as dStrError, Keys are the error code, values the error description
  • extra_compatErrorString: same as compatErrorString. The compatible error strings are
    added to the existing one, and not replacing them.

Example of extension file :

  • extra_dErrName = { ‘ELHCBSPE’ : 3001 }
  • extra_dErrorCode = { 3001 : ‘ELHCBSPE’}
  • extra_dStrError = { 3001 : “This is a description text of the specific LHCb error” }
  • extra_compatErrorString = { 3001 : [“living easy, living free”],
    DErrno.ERRX : [‘An error message for ERRX that is specific to LHCb’]}
DIRAC.Core.Utilities.DErrno.cmpError(inErr, candidate)

This function compares an error (in its old form (a string or dictionary) or in its int form with a candidate error code.

Parameters:
  • inErr (str or int or S_ERROR) – a string, an integer, a S_ERROR dictionary
  • candidate (int) – error code to compare with
Returns:

True or False

If an S_ERROR instance is passed, we compare the code with S_ERROR[‘Errno’] If it is a Integer, we do a direct comparison If it is a String, we use strerror to check the error string

DIRAC.Core.Utilities.DErrno.includeExtensionErrors()

Merge all the errors of all the extensions into the errors of these modules Should be called only at the initialization of DIRAC, so by the parseCommandLine, dirac-agent.py, dirac-service.py, dirac-executor.py

DIRAC.Core.Utilities.DErrno.strerror(code)

This method wraps up os.strerror, and behave the same way. It completes it with the DIRAC specific errors.