mirror of
https://github.com/goatcorp/Dalamud.git
synced 2026-02-18 22:07:44 +01:00
Add error handlings for UldWidget (#2011)
* Add error handlings for UldWidget * fixes
This commit is contained in:
parent
7e0c97f59e
commit
cddad72066
7 changed files with 444 additions and 213 deletions
|
|
@ -1,5 +1,6 @@
|
|||
using System.IO;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
using Dalamud.Game;
|
||||
using Dalamud.IoC;
|
||||
|
|
@ -148,6 +149,16 @@ internal sealed class DataManager : IInternalDisposableService, IDataManager
|
|||
return this.GameData.Repositories.TryGetValue(filePath.Repository, out var repository) ? repository.GetFile<T>(filePath.Category, filePath) : default;
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public Task<T> GetFileAsync<T>(string path, CancellationToken cancellationToken) where T : FileResource =>
|
||||
GameData.ParseFilePath(path) is { } filePath &&
|
||||
this.GameData.Repositories.TryGetValue(filePath.Repository, out var repository)
|
||||
? Task.Run(
|
||||
() => repository.GetFile<T>(filePath.Category, filePath) ?? throw new FileNotFoundException(
|
||||
"Failed to load file, most likely because the file could not be found."),
|
||||
cancellationToken)
|
||||
: Task.FromException<T>(new FileNotFoundException("The file could not be found."));
|
||||
|
||||
/// <inheritdoc/>
|
||||
public bool FileExists(string path)
|
||||
=> this.GameData.FileExists(path);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue