mirror of
https://github.com/space-wizards/RobustToolbox.git
synced 2026-02-15 03:30:53 +01:00
Fix TryGetResource silently eating exceptions
why god
This commit is contained in:
@@ -43,7 +43,7 @@ END TEMPLATE-->
|
||||
|
||||
### Bugfixes
|
||||
|
||||
*None yet*
|
||||
* `IResourceCache.TryGetResource<T>` won't silently eat all exceptions anymore.
|
||||
|
||||
### Other
|
||||
|
||||
@@ -401,7 +401,7 @@ END TEMPLATE-->
|
||||
|
||||
### Breaking changes
|
||||
|
||||
* Most methods in ActorSystem have been moved to ISharedPlayerManager.
|
||||
* Most methods in ActorSystem have been moved to ISharedPlayerManager.
|
||||
* Several actor/player related components and events have been moved to shared.
|
||||
|
||||
### New features
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Runtime.CompilerServices;
|
||||
using Robust.Shared.ContentPack;
|
||||
@@ -45,13 +46,13 @@ internal sealed partial class ResourceCache : ResourceManager, IResourceCacheInt
|
||||
{
|
||||
if (useFallback && resource.Fallback != null)
|
||||
{
|
||||
Logger.Error(
|
||||
Sawmill.Error(
|
||||
$"Exception while loading resource {typeof(T)} at '{path}', resorting to fallback.\n{Environment.StackTrace}\n{e}");
|
||||
return GetResource<T>(resource.Fallback.Value, false);
|
||||
}
|
||||
else
|
||||
{
|
||||
Logger.Error(
|
||||
Sawmill.Error(
|
||||
$"Exception while loading resource {typeof(T)} at '{path}', no fallback available\n{Environment.StackTrace}\n{e}");
|
||||
throw;
|
||||
}
|
||||
@@ -81,11 +82,17 @@ internal sealed partial class ResourceCache : ResourceManager, IResourceCacheInt
|
||||
cache[path] = resource;
|
||||
return true;
|
||||
}
|
||||
catch
|
||||
catch (FileNotFoundException)
|
||||
{
|
||||
resource = null;
|
||||
return false;
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Sawmill.Error($"Exception while loading resource {typeof(T)} at '{path}'\n{e}");
|
||||
resource = null;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public void ReloadResource<T>(string path) where T : BaseResource, new()
|
||||
@@ -109,7 +116,7 @@ internal sealed partial class ResourceCache : ResourceManager, IResourceCacheInt
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Logger.Error($"Exception while reloading resource {typeof(T)} at '{path}'\n{e}");
|
||||
Sawmill.Error($"Exception while reloading resource {typeof(T)} at '{path}'\n{e}");
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -35,15 +35,15 @@ namespace Robust.Shared.ContentPack
|
||||
private static readonly Regex BadPathCharacterRegex =
|
||||
new("[<>:\"|?*\0\\x01-\\x1f]", RegexOptions.IgnoreCase);
|
||||
|
||||
private ISawmill _sawmill = default!;
|
||||
protected ISawmill Sawmill = default!;
|
||||
|
||||
/// <inheritdoc />
|
||||
public IWritableDirProvider UserData { get; private set; } = default!;
|
||||
|
||||
/// <inheritdoc />
|
||||
public void Initialize(string? userData)
|
||||
public virtual void Initialize(string? userData)
|
||||
{
|
||||
_sawmill = _logManager.GetSawmill("res");
|
||||
Sawmill = _logManager.GetSawmill("res");
|
||||
|
||||
if (userData != null)
|
||||
{
|
||||
@@ -67,7 +67,7 @@ namespace Robust.Shared.ContentPack
|
||||
// no pack in config
|
||||
if (string.IsNullOrWhiteSpace(zipPath))
|
||||
{
|
||||
_sawmill.Warning("No default ContentPack to load in configuration.");
|
||||
Sawmill.Warning("No default ContentPack to load in configuration.");
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -91,7 +91,7 @@ namespace Robust.Shared.ContentPack
|
||||
|
||||
//create new PackLoader
|
||||
|
||||
var loader = new PackLoader(packInfo, _sawmill);
|
||||
var loader = new PackLoader(packInfo, Sawmill);
|
||||
AddRoot(prefix.Value, loader);
|
||||
}
|
||||
|
||||
@@ -99,7 +99,7 @@ namespace Robust.Shared.ContentPack
|
||||
{
|
||||
prefix = SanitizePrefix(prefix);
|
||||
|
||||
var loader = new PackLoader(zipStream, _sawmill);
|
||||
var loader = new PackLoader(zipStream, Sawmill);
|
||||
AddRoot(prefix.Value, loader);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user