Files
Ben Marsh f77f72cd32 Horde: More refactoring of storage API to hide bundle implementation details.
- Rename StorageClientBase to BundleStorageClient. The current implementation assumes that bundles will be used for storage.
- Use ReadAsync() methods on NodeHandle to expand content, rather than requiring a TreeReader to be passed around.

#preflight none

[CL 25737520 by Ben Marsh in ue5-main branch]
2023-06-01 15:43:22 -04:00

57 lines
1.6 KiB
C#

// Copyright Epic Games, Inc. All Rights Reserved.
using System;
using System.Net;
using EpicGames.Core;
using Horde.Server.Utilities;
using Microsoft.AspNetCore.Diagnostics;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Logging;
namespace Horde.Server.Server
{
/// <summary>
/// Controller managing account status
/// </summary>
[ApiController]
[Route("[controller]")]
public class ExceptionController : HordeControllerBase
{
/// <summary>
/// Outputs a diagnostic error response for an exception
/// </summary>
[Route("/api/v1/exception")]
[ApiExplorerSettings(IgnoreApi = true)]
public ActionResult Exception()
{
IExceptionHandlerPathFeature? feature = HttpContext.Features.Get<IExceptionHandlerPathFeature>();
int statusCode = (int)HttpStatusCode.InternalServerError;
LogEvent logEvent;
if (feature == null)
{
logEvent = LogEvent.Create(LogLevel.Error, "Exception handler path feature is missing.");
}
else if (feature.Error == null)
{
logEvent = LogEvent.Create(LogLevel.Information, "No error code.");
}
else if (feature.Error is StructuredHttpException structuredHttpEx)
{
(logEvent, statusCode) = (structuredHttpEx.ToLogEvent(), structuredHttpEx.StatusCode);
}
else if (feature.Error is StructuredException structuredEx)
{
logEvent = structuredEx.ToLogEvent();
}
else
{
logEvent = LogEvent.Create(LogLevel.Error, default, feature.Error, "Unhandled exception: {Message}", feature.Error.Message);
}
return new ObjectResult(logEvent) { StatusCode = statusCode };
}
}
}