Skip to content

Game.Modding.Toolchain.ToolchainException

Assembly:
Game

Namespace: Game.Modding.Toolchain

Type: class

Base: System.Exception

Summary: Represents an exception raised by the toolchain subsystem when an operation involving a toolchain dependency fails. Carries an explicit ToolchainError value and the IToolchainDependency that caused or is associated with the failure. Intended for use by toolchain-related code to surface typed error information (enum + source dependency) in addition to the usual exception message and inner exception.


Fields

  • private System.Runtime.CompilerServices.StrongBox<System.Object> <source>k__BackingField
    Compiler-generated backing field for the read-only auto-property source. Not present in source code explicitly; generated by the C# compiler for the auto-property.

  • private System.Runtime.CompilerServices.StrongBox<System.Object> <error>k__BackingField
    Compiler-generated backing field for the read-only auto-property error. Not present in source code explicitly; generated by the C# compiler for the auto-property.

(Note: The actual generated field names are <source>k__BackingField and <error>k__BackingField. They are implementation details and should not be accessed directly.)

Properties

  • public IToolchainDependency source { get; }
    Gets the dependency instance associated with this error. This property identifies which toolchain dependency (e.g., a specific tool or package) caused or is related to the error. Useful for logging, diagnostics, or to attempt dependency-specific recovery.

  • public ToolchainError error { get; }
    Gets the ToolchainError value that classifies the kind of error that occurred (for example, missing executable, wrong version, failed execution, etc.). Prefer inspecting this enum to determine error-specific handling logic rather than relying solely on message text.

Constructors

  • public ToolchainException(ToolchainError error, IToolchainDependency source, string message = null, Exception innerException = null)
    Creates a new ToolchainException with the provided error enum, the dependency that caused the error, an optional message and optional inner exception. Use this constructor to propagate both typed error information and conventional exception details.

  • public ToolchainException(ToolchainError status, IToolchainDependency source, Exception innerException)
    Convenience constructor that forwards to the primary constructor using an empty string as the message and the provided innerException. Equivalent to calling the other constructor with message = string.Empty.

Methods

  • None declared in this class beyond inherited members from System.Exception. The class only stores additional context (error enum and source dependency) and relies on Exception base behavior (Message, StackTrace, InnerException, etc.).

Usage Example

// Example of throwing a ToolchainException when a dependency check fails:
IToolchainDependency compilerDependency = ...;
if (!compilerDependency.IsAvailable)
{
    throw new ToolchainException(
        ToolchainError.MissingDependency,
        compilerDependency,
        $"Required tool '{compilerDependency.Name}' was not found on PATH.");
}

// Example of catching and inspecting:
try
{
    toolchainRunner.Run();
}
catch (ToolchainException ex)
{
    Debug.LogError($"Toolchain error: {ex.error} (dependency: {ex.source?.Name}) - {ex.Message}");
    // Take error-specific actions based on ex.error
}