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

# XErrorSetCallback

> XErrorSetCallback

# XErrorSetCallback

게이밍 OS 또는 게이밍 런타임에서 오류가 발생하면 호출되는 콜백을 지정합니다.

## 구문

```cpp theme={null}
void XErrorSetCallback(  
         XErrorCallback* callback,  
         void* context  
)  
```

### 매개 변수

*callback*   \_In\_\
형식: XErrorCallback\*

호출할 게임 정의 콜백에 대한 포인터입니다. `nullptr`을 전달하면 콜백이 지워집니다.

*context*   \_In\_\
형식: void\*

콜백에 대한 컨텍스트 포인터입니다.

### 반환 값

형식: void

## 설명

<Note>이 함수는 시간에 민감한 스레드에서 호출하기에 안전하지 않습니다. 자세한 내용은 [시간에 민감한 스레드](https://learn.microsoft.com/gaming/gdk/docs/gdk-dev/console-dev/overviews/threads/time-sensitive-threads)를 참조하세요.</Note>

게임에서 오류가 발생할 경우 시스템이 호출해야 하는 [XErrorCallback](/reference/system/xerror/functions/xerrorcallback) 콜백을 지정하려면 이 함수를 사용하고, 게이밍 OS 또는 게이밍 런타임에서 오류가 발생할 때 게임이 동작하는 방식을 지정하려면 [XErrorSetOptions](/reference/system/xerror/functions/xerrorsetoptions) 함수를 사용합니다.

다음 예제는 오류 옵션을 설정하고, 사용자 지정 오류 콜백을 정의하고, 시스템에서 오류 알림을 수신하도록 사용자 지정 오류 콜백을 설정하는 방법을 보여 줍니다.

```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);
}  
```

## 요구 사항

**헤더:** XError.h

**라이브러리:** xgameruntime.lib

**지원 플랫폼:** Windows, XBOX One 계열 콘솔 및 XBOX Series 콘솔

## 개념 문서

* [시간에 민감한 스레드](https://learn.microsoft.com/gaming/gdk/docs/gdk-dev/console-dev/overviews/threads/time-sensitive-threads)

## 함께 보기

[XError 멤버](/reference/system/xerror/xerror_members)\
[XErrorCallback](/reference/system/xerror/functions/xerrorcallback)


## Related topics

- [XErrorCallback](/ko/reference/system/xerror/functions/xerrorcallback.md)
- [XError members](/ko/reference/system/xerror/xerror_members.md)
- [PartyManager::SetMemoryCallbacks](/ko/services/playfab/multiplayer/networking/reference/classes/PartyManager/methods/partymanager_setmemorycallbacks.md)
- [PartyXblManager::SetMemoryCallbacks](/ko/services/playfab/multiplayer/networking/xblreference/classes/PartyXblManager/methods/partyxblmanager_setmemorycallbacks.md)
- [XGameUiShowErrorDialogUiCallback](/ko/reference/system/xgameui/functions/xgameuishowerrordialoguicallback.md)
