> ## 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

ゲーミング OS またはゲーミング ランタイムでエラーが発生したときの目的の動作を指定します。

## Syntax

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

### Parameters

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

デバッガーがアタッチされているときの目的の動作を指定します。

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

デバッガーがアタッチされていないときの目的の動作を指定します。

### Return value

型: void

## Remarks

<Note>この関数は、タイム センシティブ スレッドから呼び出しても安全ではありません。詳細については、[Time-sensitive threads](https://learn.microsoft.com/gaming/gdk/docs/gdk-dev/console-dev/overviews/threads/time-sensitive-threads) を参照してください。</Note>

この関数を使用して、ゲーミング OS またはゲーミング ランタイムでエラーが発生したときにゲームがどのように反応するべきかを指定します。既定では、デバッガーがアタッチされていない場合ゲームは何もしませんが、デバッガーがアタッチされている場合はデバッガーにデバッグ メッセージを出力します。

デバッガーがアタッチされ、*optionsDebuggerPresent* が \[XErrorOptions::DebugBreakOnError] に設定されている場合、システムはデバッガーにブレークインし、デバッグ メッセージを出力します。この動作は、ウォッチ ウィンドウでグローバル変数 `XErrorDisableDebugBreak` の値を `true` に設定することで一時的に無効にできます。

次の例は、エラー オプションを設定する方法、カスタム エラー コールバックを定義する方法、およびシステムからエラー通知を受け取るためにカスタム コールバックを設定する方法を示します。

```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

**ヘッダー:** XError.h

**ライブラリ:** xgameruntime.lib

**サポートされているプラットフォーム:** Windows、XBOX One ファミリー本体および XBOX Series 本体

## 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](/ja-jp/reference/system/xerror/enums/xerroroptions.md)
- [XErrorCallback](/ja-jp/reference/system/xerror/functions/xerrorcallback.md)
- [XError members](/ja-jp/reference/system/xerror/xerror_members.md)
- [XErrorSetCallback](/ja-jp/reference/system/xerror/functions/xerrorsetcallback.md)
- [XMemSetOption](/ja-jp/reference/system/xmem/functions/xmemsetoption.md)
