This commit is contained in:
Paul Schneider 2026-11-21 21:14:34 +00:00
commit 3bf7dd88f5
Signed by: notazof
GPG key ID: AD4B9B545FBD7D12
3 changed files with 34 additions and 9 deletions

View file

@ -0,0 +1,21 @@
using System;
namespace Yavsc.Exceptions;
public class NoTokenException : Exception
{
public NoTokenException()
: base("No token available.")
{
}
public NoTokenException(string message)
: base(message)
{
}
public NoTokenException(string message, Exception innerException)
: base(message, innerException)
{
}
}

View file

@ -0,0 +1,10 @@
using System;
namespace PostIt.Services;
public sealed class RefreshFailedException : Exception
{
public bool IsPermanent { get; }
public RefreshFailedException(string message, bool isPermanent)
: base(message) => IsPermanent = isPermanent;
}

View file

@ -11,6 +11,7 @@ using IdentityModel.OidcClient;
using PostIt.ViewModels;
using Yavsc.ApiControllers;
using Yavsc.Api.Client;
using Yavsc.Exceptions;
namespace PostIt.Services;
@ -547,10 +548,10 @@ public class YavscApiClient : IYavscApiClient, IAsyncDisposable
try
{
if (IsSigningOut)
throw new InvalidOperationException("Deconnexion en cours.");
throw new NoTokenException("Deconnexion en cours.");
var tokens = _tokens;
if (tokens is null)
throw new InvalidOperationException("Session expirée. Veuillez vous reconnecter.");
throw new NoTokenException("Session expirée. Veuillez vous reconnecter.");
if (string.IsNullOrEmpty(tokens.RefreshToken))
{
_store.Clear();
@ -852,10 +853,3 @@ public class YavscApiClient : IYavscApiClient, IAsyncDisposable
}
}
}
public sealed class RefreshFailedException : Exception
{
public bool IsPermanent { get; }
public RefreshFailedException(string message, bool isPermanent)
: base(message) => IsPermanent = isPermanent;
}