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

# XErrorCallback

> XErrorCallback

# XErrorCallback

ゲーミング OS またはゲーミング ランタイムでエラーが発生した場合に呼び出されるコールバック。

## Syntax

```cpp theme={null}
bool XErrorCallback(  
         HRESULT hr,  
         const char* msg,  
         void* context  
)  
```

### Parameters

*hr*   \_In\_\
型: HRESULT

エラーに関連付けられた HRESULT コード。

*msg*   \_In\_z\_\
型: char\*

エラーのテキスト説明。

*context*   \_In\_\
型: void\*

コールバックのコンテキスト ポインター。

### Return value

型: bool

システムが処理を続行して、[XErrorSetOptions](/reference/system/xerror/functions/xerrorsetoptions) で指定されたことを実行するように指示するには `true` を返します。それ以外の場合、エラーを無視するには `false` を返します。

## Remarks

[XErrorSetCallback](/reference/system/xerror/functions/xerrorsetcallback) 関数を使用して、エラーが発生した場合にシステムが呼び出す必要のあるゲーム内の `XErrorCallback` コールバックを指定し、`XErrorSetOptions` 関数を使用して、ゲーミング OS またはゲーミング ランタイムでエラーが発生したときにゲームがどのように動作するべきかを指定します。

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

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

## See also

[XError members](/reference/system/xerror/xerror_members)\
[XErrorSetCallback](/reference/system/xerror/functions/xerrorsetcallback)


## Related topics

- [XErrorSetCallback](/ja-jp/reference/system/xerror/functions/xerrorsetcallback.md)
- [XError members](/ja-jp/reference/system/xerror/xerror_members.md)
- [XMemCreateWin32Heap](/ja-jp/reference/system/xmem/functions/xmemcreatewin32heap.md)
- [WdCopyErrorCallback](/ja-jp/reference/remoting/callbacks/wdcopyerrorcallback.md)
- [XtfDebugStringErrorCallback](/ja-jp/reference/tools/xtf/xtfapi/functions/xtfdebugstringerrorcallback-xtfapi-xbox-windows-m.md)
