parameters: (status, exc_info=None)
return_statement: return buildError
docstring: Convert any return code a BuildError Exception.
  
      :Parameters:
        - `status`: can either be a return code or an Exception.
  
      The buildError.status we set here will normally be
      used as the exit status of the "scons" process.
docstring_summary: Convert any return code a BuildError Exception.
docstring_tokens: Convert any return code a BuildError Exception .
function: def convert_to_BuildError(status, exc_info=None):
      """
      Convert any return code a BuildError Exception.
  
      :Parameters:
        - `status`: can either be a return code or an Exception.
  
      The buildError.status we set here will normally be
      used as the exit status of the "scons" process.
      """
  
      if not exc_info and isinstance(status, Exception):
          exc_info = (status.__class__, status, None)
  
  
      if isinstance(status, BuildError):
          buildError = status
          buildError.exitstatus = 2   # always exit with 2 on build errors
      elif isinstance(status, ExplicitExit):
          status = status.status
          errstr = 'Explicit exit, status %s' % status
          buildError = BuildError(
              errstr=errstr,
              status=status,      # might be 0, OK here
              exitstatus=status,      # might be 0, OK here
              exc_info=exc_info)
      elif isinstance(status, (StopError, UserError)):
          buildError = BuildError(
              errstr=str(status),
              status=2,
              exitstatus=2,
              exc_info=exc_info)
      elif isinstance(status, shutil.SameFileError):
          # PY3 has a exception for when copying file to itself
          # It's object provides info differently than below
          try:
              filename = status.filename
          except AttributeError:
              filename = None
          
          buildError = BuildError( 
              errstr=status.args[0],
              status=status.errno,
              exitstatus=2,
              filename=filename,
              exc_info=exc_info)
  
      elif isinstance(status, (EnvironmentError, OSError, IOError)):
          # If an IOError/OSError happens, raise a BuildError.
          # Report the name of the file or directory that caused the
          # error, which might be different from the target being built
          # (for example, failure to create the directory in which the
          # target file will appear).
          try:
              filename = status.filename
          except AttributeError:
              filename = None
  
          buildError = BuildError( 
              errstr=status.strerror,
              status=status.errno,
              exitstatus=2,
              filename=filename,
              exc_info=exc_info)
      elif isinstance(status, Exception):
          buildError = BuildError(
              errstr='%s : %s' % (status.__class__.__name__, status),
              status=2,
              exitstatus=2,
              exc_info=exc_info)
      elif SCons.Util.is_String(status):
          buildError = BuildError(
              errstr=status,
              status=2,
              exitstatus=2)
      else:
          buildError = BuildError(
              errstr="Error %s" % status,
              status=status,
              exitstatus=2)
      
      #import sys
      #sys.stderr.write("convert_to_BuildError: status %s => (errstr %s, status %s)\n"%(status,buildError.errstr, buildError.status))
      return buildError
function_tokens: def convert_to_BuildError ( status , exc_info = None ) : if not exc_info and isinstance ( status , Exception ) : exc_info = ( status . __class__ , status , None ) if isinstance ( status , BuildError ) : buildError = status buildError . exitstatus = 2 # always exit with 2 on build errors elif isinstance ( status , ExplicitExit ) : status = status . status errstr = 'Explicit exit, status %s' % status buildError = BuildError ( errstr = errstr , status = status , # might be 0, OK here exitstatus = status , # might be 0, OK here exc_info = exc_info ) elif isinstance ( status , ( StopError , UserError ) ) : buildError = BuildError ( errstr = str ( status ) , status = 2 , exitstatus = 2 , exc_info = exc_info ) elif isinstance ( status , shutil . SameFileError ) : # PY3 has a exception for when copying file to itself # It's object provides info differently than below try : filename = status . filename except AttributeError : filename = None buildError = BuildError ( errstr = status . args [ 0 ] , status = status . errno , exitstatus = 2 , filename = filename , exc_info = exc_info ) elif isinstance ( status , ( EnvironmentError , OSError , IOError ) ) : # If an IOError/OSError happens, raise a BuildError. # Report the name of the file or directory that caused the # error, which might be different from the target being built # (for example, failure to create the directory in which the # target file will appear). try : filename = status . filename except AttributeError : filename = None buildError = BuildError ( errstr = status . strerror , status = status . errno , exitstatus = 2 , filename = filename , exc_info = exc_info ) elif isinstance ( status , Exception ) : buildError = BuildError ( errstr = '%s : %s' % ( status . __class__ . __name__ , status ) , status = 2 , exitstatus = 2 , exc_info = exc_info ) elif SCons . Util . is_String ( status ) : buildError = BuildError ( errstr = status , status = 2 , exitstatus = 2 ) else : buildError = BuildError ( errstr = "Error %s" % status , status = status , exitstatus = 2 ) #import sys #sys.stderr.write("convert_to_BuildError: status %s => (errstr %s, status %s)\n"%(status,buildError.errstr, buildError.status)) return buildError