# Error Handling in Blueprints

## Format Log Message Node

We have implemented "Format Message", which is an improved version of Unreal's
"Format Text".  Unlike "Format Text", it has built-in support to print
vectors, rotations, enums, and quite a few other types.

We have also implemented "Format Log Message", which is like Format Message
except that the output goes to the unreal logs.  It might help to familiarize
yourself with Unreal's built-in logging function, UE_LOG.  Format Log Message
is meant to be the Blueprint front end to UE_LOG.

Format Message and Format Log Message both require a format string, which
will typically look something like this:

    "Hello, {Name}, the weather today will be {Weather}"

When you set a format string such as the one above, the Format Message node
will add pins for the placeholders - in the example above, the pins
Name and Weather would be added.  These are wildcard pins that you can
connect any printable value to.

To make a new type printable, look at FormatDataLibrary.h

Format Log Message accepts a severity level, this is directly based on
the severity levels supported by UE_LOG.  It adds *ThrottledDisplay* and
*ThrottledLog*, which do the same thing as *Display* and *Log*, except
that output is limited to one message per second.

## The Blueprint Debugger Pauses on Error Messages

The blueprint debugger will pause whenever you log an error message.  This is functionality we have added to Unreal.
You can control the severity at which it pauses: in the GameMode, there is a dropdown for the severity level.
You can also effectively turn it off by telling to only pause on fatal errors.

There is a quirk: the debugger pauses before the error gets put into the logs.  So when you're in the
blueprint debugger,
the only place the error will appear is in the lower-right corner of the screen, where debugger messages are
reported.  You won't see the error in the unreal output log.  If you single-step, the error will appear
in the output log as well.

To understand how this is implemented, it helps to understand that log messages in unreal go to a bunch of
different output devices: the unreal editor output window, the visual studio output window, a log file, and
several more places.  To dispatch messages to all these different destinations, Unreal has an output device
list that you can add an output device to.

To implement this break-on-error-message functionality, we implemented a pseudo-output-device.
The pseudo device doesn't actually send
the error message anywhere, it just triggers the debugger.  For more information about implementation,
see BreakToDebugger.h

