// Copyright Epic Games, Inc. All Rights Reserved. using System; using System.Collections.Generic; using EpicGames.Core; using Microsoft.Extensions.Logging; namespace HordeServer.Utilities { /// /// Exception class designed to allow logging structured log messages /// public class StructuredException : Exception { /// /// Format string for the message /// public string Format { get; } /// /// Arguments for holes in the format string /// public IReadOnlyList Args { get; } /// /// Constructor /// /// Message template for the log message /// Arguments to render public StructuredException(string format, params object[] args) { Format = format; Args = args; } /// /// Creates a log event from this exception /// public LogEvent ToLogEvent() { return LogEvent.Create(LogLevel.Error, default, this, Format, Args); } } /// /// Exception class designed to allow logging structured log messages /// public class StructuredHttpException : StructuredException { /// /// Status code /// public int StatusCode { get; } /// /// Constructor /// /// Status code for the response /// Message template for the log message /// Arguments to render public StructuredHttpException(int statusCode, string format, params object[] args) : base(format, args) { StatusCode = statusCode; } } }