Skip to content

ErrorBody

INCLUDE FILE
#include "Body/ErrorBody.h"

class ErrorBody

Represents a body that reports an error when encoded. It can be used with conditional compilation to report errors when certain conditions are met: .error message.

DEFINITION
class ErrorBody;

constructor ErrorBody

DEFINITION
ErrorBody ( const Location & location,
std::string  message );
PARAMETERDESCRIPTION
location
message

method cloneconst virtual

DEFINITION
virtual Body  clone ( const CloneContext & context ) const;
PARAMETERDESCRIPTION
context
RETURNSDESCRIPTION
Body

method createstatic

DEFINITION
static Body  create ( const Location & location,
std::string  message );
PARAMETERDESCRIPTION
location
message
RETURNSDESCRIPTION
Body

method encodevirtual

Encode the BodyElement into a byte string.

The default implementation does nothing. Subclasses that represent data or instructions should override this method.

DEFINITION
virtual void  encode ( std::string & bytes,
const Memory * memory );
PARAMETERDESCRIPTION
bytes

The byte string to encode into.

memory

The memory context for encoding.

method evaluatevirtual

Evaluate the BodyElement in a given context.

Subclasses must implement this method.

If an error occurs during evaluation, either an error should be reported via DiagnosticOutput and the BodyElement marked as invalid, or an exception should be thrown.

DEFINITION
virtual std::optional< Body >  evaluate ( const EvaluationContext & context );
PARAMETERDESCRIPTION
context

The evaluation context.

RETURNSDESCRIPTION
std::optional< Body >

The Body to replace this BodyElement with, {} if no replacement is needed.

method serializeconst virtual

Serialize the BodyElement to a stream.

Subclasses must implement this method.

DEFINITION
virtual void  serialize ( std::ostream & stream,
const std::string & prefix ) const;
PARAMETERDESCRIPTION
stream

The stream to serialize to.

prefix

The prefix for each line of the serialized output.

member location

DEFINITION
Location  location;

member message

DEFINITION
std::string  message;