> ## Documentation Index
> Fetch the complete documentation index at: https://devdocs.xbox.com/llms.txt
> Use this file to discover all available pages before exploring further.

# XErrorSetOptions

> XErrorSetOptions

# XErrorSetOptions

Specifies the desired behavior when an error occurs in the gaming OS or gaming runtime.

## Syntax

```cpp theme={null}
void XErrorSetOptions(  
         XErrorOptions optionsDebuggerPresent,  
         XErrorOptions optionsDebuggerNotPresent  
)  
```

### Parameters

*optionsDebuggerPresent*   \_In\_\
Type: [XErrorOptions](/reference/system/xerror/enums/xerroroptions)

Specifies the desired behavior when the debugger is attached.

*optionsDebuggerNotPresent*   \_In\_\
Type: [XErrorOptions](/reference/system/xerror/enums/xerroroptions)

Specifies the desired behavior when the debugger is not attached.

### Return value

Type: void

## Remarks

<Note>This function isn't safe to call on a time-sensitive thread. For more information, see [Time-sensitive threads](https://learn.microsoft.com/gaming/gdk/docs/gdk-dev/console-dev/overviews/threads/time-sensitive-threads).</Note>

Use this function to specify how the game should react when an error occurs in the gaming OS or gaming runtime. By default, the game does nothing if a debugger isn't attached and outputs debug messages to the debugger if it's attached.

If a debugger is attached and *optionsDebuggerPresent* is set to \[XErrorOptions::DebugBreakOnError], the system breaks into the debugger and outputs debug messages. You can temporarily disable this behavior through the watch window by setting the value of the global variable, `XErrorDisableDebugBreak`, to `true`.

The following example illustrates how to set error options, define a custom error callback, and set the custom callback to receive error notifications by the system.

```cpp theme={null}
bool CustomGameXErrorCallback(_In_ HRESULT hr, _In_ const char* msg, _In_ void* context)  
{  
   // Capture the error to the game's custom logger  
   CustomGameLogger* logger = (CustomGameLogger*)context;  
   logger->ReportGameRuntimeIssue(hr, msg);  
  
   // Don't ignore the error. For example, continue on and do whatever  
   // is specified by XErrorSetOptions().  
   return true;  
}  
  
void SomeGameFunction()  
{  
   // Previously initialize the game's custom logger  
   // CustomGameLogger* m_logger = InitializeLogger();  
   // ...  
  
   // Setup how you want to handle XErrors  
   XErrorSetOptions(DebugBreakOnError, FailFastOnError);
   XErrorSetCallback(CustomGameXErrorCallback, m_logger);
}  
```

## Requirements

**Header:** XError.h

**Library:** xgameruntime.lib

**Supported platforms:** Windows, XBOX One family consoles and XBOX Series consoles

## Conceptual documentation

* [Time-sensitive threads](https://learn.microsoft.com/gaming/gdk/docs/gdk-dev/console-dev/overviews/threads/time-sensitive-threads)

## See also

[XError members](/reference/system/xerror/xerror_members)\
[XErrorOptions](/reference/system/xerror/enums/xerroroptions)


## Related topics

- [XErrorOptions](/reference/system/xerror/enums/xerroroptions.md)
- [XErrorSetCallback](/reference/system/xerror/functions/xerrorsetcallback.md)
- [XErrorCallback](/reference/system/xerror/functions/xerrorcallback.md)
- [XError members](/reference/system/xerror/xerror_members.md)
- [XMemSetOption](/reference/system/xmem/functions/xmemsetoption.md)
