xpybuild.utils.buildexceptions

The xpybuild.utils.buildexceptions.BuildException class used for (non-internal) problems encountered while building.

BuildException

class xpybuild.utils.buildexceptions.BuildException(message, location=None, causedBy=False)[source]

Bases: Exception

A BuildException represents an error caused by an incorrect build or a runtime build problem. i.e. anything that isn’t an internal xpybuild error.

Typically a BuildException will not result in a python stack trace being printed whereas other exception types will, so only raise one if you’re sure the message includes all required diagnostic information already.

BuildExceptions thrown during loading of the build config files will include the build file location (from their call stack) in the message. BuildExceptions thrown during operations on a target (dep resolution, execution, cleaning) will have information about that target added by xpybuild when it is logged, so there is usually no reason to explicitly add the target name into the message.

To avoid losing essential diagnostic information, do not catch arbitrary non-BuildException classes and wrap in a BuildException.

The location can optionally be specified explicitly (e.g. for pathsets with delayed evaluation).

Parameters
  • message – the error cause (does not need to include the target name)

  • location – usually None, or else a BuildFileLocation object for the source line that caused the problem. This is useful if the build file location associated with the exception is something other than a target, e.g. a PathSet.

  • causedBy – if True, takes the exception currently on the stack as the caused of this exception, and adds it to the build exception message. If the cause is not a BuildException, then its stack trace will be captured if this is True.

getLoggerExtraArgDict(target=None)[source]

Returns a dict suitable for passing as extra= in a logger call, to set filename/lineno location information if available.

Parameters

target – optionally used to find location if not available in this exception

toSingleLineString(target)[source]

Return the exception message formatted to be a single line.

Includes the name of the failed target if called with a target.

Parameters

target – The target causing the exception.

toMultiLineString(target, includeStack=False)[source]

Return the exception message, on multiple lines if necessary, possibly including the stack trace.

If possible, includes the build file location associated with the exception or with the failed target.

Parameters
  • target – The target causing the exception.

  • includeStack – If true, also includes the stack trace of the exception.