Table of Contents

Class ErrorFormatter

Namespace
GrindFest.GameMaster.Helpers
Assembly
GrindFest.dll

Helper class for formatting detailed error information for MCP tools. Provides comprehensive exception details including stack traces and inner exceptions.

public static class ErrorFormatter
Inheritance
object
ErrorFormatter

Methods

FormatError(string, string, object)

Formats a simple error message into JSON format. Use this for validation errors or expected error conditions.

FormatException(Exception, string, object)

Formats an exception into a detailed JSON error response for MCP tools. Includes exception type, message, stack trace, inner exceptions (recursively), and tool context. Also logs the exception to Unity console for debugging.

FormatSuccess(string, string, object)

Formats a success message into JSON format. Use this for successful tool executions to maintain consistent response format.

LogException(Exception, string, object)

Logs an exception to Unity console with detailed information. Use this for void-returning tools that cannot return JSON error responses. Recursively logs all inner exceptions.