#nullable enable
using System;
using System.Globalization;
namespace SharpGen.Runtime
{
public partial class SharpGenException
{
///
/// Initializes a new instance of the class.
///
public SharpGenException() : this(Result.Fail, "A SharpGen exception occurred.")
{
}
///
/// Initializes a new instance of the class.
///
/// The result code that caused this exception.
/// The exception that caused this exception.
public SharpGenException(Result result, Exception? innerException = null)
: this(ResultDescriptor.Find(result), innerException: innerException)
{
}
///
/// Initializes a new instance of the class.
///
/// The error result code.
/// The message describing the exception.
/// The exception that caused this exception.
public SharpGenException(Result result, string message, Exception? innerException = null)
: this(result, null, message, innerException)
{
}
///
/// Initializes a new instance of the class.
///
/// The result descriptor.
/// The message describing the exception.
/// The exception that caused this exception.
public SharpGenException(ResultDescriptor descriptor, string? message = null, Exception? innerException = null)
: this(descriptor.Result, descriptor, message ?? descriptor.ToString(), innerException)
{
}
///
/// Initializes a new instance of the class.
///
/// The error result code.
/// The message describing the exception.
/// The exception that caused this exception.
/// The message formatting arguments
public SharpGenException(Result result, string message, Exception? innerException = null, params object[] args)
: this(result, null, string.Format(CultureInfo.InvariantCulture, message, args), innerException)
{
}
///
/// Initializes a new instance of the class.
///
/// The result descriptor.
/// The message describing the exception.
/// The exception that caused this exception.
/// The message formatting arguments
public SharpGenException(ResultDescriptor descriptor, string message, Exception? innerException = null,
params object[] args)
: this(descriptor.Result, descriptor, string.Format(CultureInfo.InvariantCulture, message, args),
innerException)
{
}
///
/// Initializes a new instance of the class.
///
/// The message describing the exception.
/// The exception that caused this exception.
/// The message formatting arguments
public SharpGenException(string message, Exception? innerException = null, params object[] args)
: this(Result.Fail, message, innerException, args)
{
}
}
}