Add better error messages for license denial #352
This commit is contained in:
parent
a0dd2ccad6
commit
94469cae3d
6 changed files with 98 additions and 71 deletions
|
|
@ -7,6 +7,8 @@ using System.Runtime.CompilerServices;
|
|||
using System.Threading.Tasks;
|
||||
using System.Windows.Forms;
|
||||
using ApplicationServices;
|
||||
using AudibleApi.Common;
|
||||
using AudibleApi;
|
||||
using DataLayer;
|
||||
using Dinah.Core;
|
||||
using Dinah.Core.ErrorHandling;
|
||||
|
|
@ -24,7 +26,9 @@ namespace LibationWinForms.ProcessQueue
|
|||
ValidationFail,
|
||||
FailedRetry,
|
||||
FailedSkip,
|
||||
FailedAbort
|
||||
FailedAbort,
|
||||
LicenseDenied,
|
||||
LicenseDeniedPossibleOutage
|
||||
}
|
||||
|
||||
public enum ProcessBookStatus
|
||||
|
|
@ -108,18 +112,31 @@ namespace LibationWinForms.ProcessQueue
|
|||
return Result = ProcessBookResult.Success;
|
||||
else if (statusHandler.Errors.Contains("Cancelled"))
|
||||
{
|
||||
Logger.Info($"{procName}: Process was cancelled {LibraryBook.Book}");
|
||||
Logger.Info($"{procName}: Process was cancelled - {LibraryBook.Book}");
|
||||
return Result = ProcessBookResult.Cancelled;
|
||||
}
|
||||
else if (statusHandler.Errors.Contains("Validation failed"))
|
||||
{
|
||||
Logger.Info($"{procName}: Validation failed {LibraryBook.Book}");
|
||||
Logger.Info($"{procName}: Validation failed - {LibraryBook.Book}");
|
||||
return Result = ProcessBookResult.ValidationFail;
|
||||
}
|
||||
|
||||
foreach (var errorMessage in statusHandler.Errors)
|
||||
Logger.Error($"{procName}: {errorMessage}");
|
||||
}
|
||||
catch (ContentLicenseDeniedException ldex)
|
||||
{
|
||||
if (ldex.AYCL?.RejectionReason is null or RejectionReason.GenericError)
|
||||
{
|
||||
Logger.Info($"{procName}: Content license was denied, but this error appears to be caused by a temporary interruption of service. - {LibraryBook.Book}");
|
||||
return Result = ProcessBookResult.LicenseDeniedPossibleOutage;
|
||||
}
|
||||
else
|
||||
{
|
||||
Logger.Info($"{procName}: Content license denied. Check your Audible account to see if you have access to this title. - {LibraryBook.Book}");
|
||||
return Result = ProcessBookResult.LicenseDenied;
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Logger.Error(ex, procName);
|
||||
|
|
|
|||
|
|
@ -60,68 +60,34 @@ namespace LibationWinForms.ProcessQueue
|
|||
|
||||
public void SetResult(ProcessBookResult result)
|
||||
{
|
||||
string statusText = default;
|
||||
switch (result)
|
||||
(string statusText, ProcessBookStatus status) = result switch
|
||||
{
|
||||
case ProcessBookResult.Success:
|
||||
statusText = "Finished";
|
||||
Status = ProcessBookStatus.Completed;
|
||||
break;
|
||||
case ProcessBookResult.Cancelled:
|
||||
statusText = "Cancelled";
|
||||
Status = ProcessBookStatus.Cancelled;
|
||||
break;
|
||||
case ProcessBookResult.FailedRetry:
|
||||
statusText = "Error, will retry later";
|
||||
Status = ProcessBookStatus.Failed;
|
||||
break;
|
||||
case ProcessBookResult.FailedSkip:
|
||||
statusText = "Error, Skippping";
|
||||
Status = ProcessBookStatus.Failed;
|
||||
break;
|
||||
case ProcessBookResult.FailedAbort:
|
||||
statusText = "Error, Abort";
|
||||
Status = ProcessBookStatus.Failed;
|
||||
break;
|
||||
case ProcessBookResult.ValidationFail:
|
||||
statusText = "Validion fail";
|
||||
Status = ProcessBookStatus.Failed;
|
||||
break;
|
||||
case ProcessBookResult.None:
|
||||
statusText = "UNKNOWN";
|
||||
Status = ProcessBookStatus.Failed;
|
||||
break;
|
||||
}
|
||||
ProcessBookResult.Success => ("Finished", ProcessBookStatus.Completed),
|
||||
ProcessBookResult.Cancelled => ("Cancelled", ProcessBookStatus.Cancelled),
|
||||
ProcessBookResult.FailedRetry => ("Error, will retry later", ProcessBookStatus.Failed),
|
||||
ProcessBookResult.FailedSkip => ("Error, Skippping", ProcessBookStatus.Failed),
|
||||
ProcessBookResult.FailedAbort => ("Error, Abort", ProcessBookStatus.Failed),
|
||||
ProcessBookResult.ValidationFail => ("Validion fail", ProcessBookStatus.Failed),
|
||||
ProcessBookResult.LicenseDenied => ("License Denied", ProcessBookStatus.Failed),
|
||||
ProcessBookResult.LicenseDeniedPossibleOutage => ("Possible Service Interruption", ProcessBookStatus.Failed),
|
||||
_ => ("UNKNOWN", ProcessBookStatus.Failed),
|
||||
};
|
||||
|
||||
SetStatus(Status, statusText);
|
||||
SetStatus(status, statusText);
|
||||
}
|
||||
|
||||
public void SetStatus(ProcessBookStatus status, string statusText = null)
|
||||
{
|
||||
Color backColor = default;
|
||||
switch (status)
|
||||
Status = status;
|
||||
|
||||
Color backColor = Status switch
|
||||
{
|
||||
case ProcessBookStatus.Completed:
|
||||
backColor = SuccessColor;
|
||||
Status = ProcessBookStatus.Completed;
|
||||
break;
|
||||
case ProcessBookStatus.Cancelled:
|
||||
backColor = CancelledColor;
|
||||
Status = ProcessBookStatus.Cancelled;
|
||||
break;
|
||||
case ProcessBookStatus.Queued:
|
||||
backColor = QueuedColor;
|
||||
Status = ProcessBookStatus.Queued;
|
||||
break;
|
||||
case ProcessBookStatus.Working:
|
||||
backColor = QueuedColor;
|
||||
Status = ProcessBookStatus.Working;
|
||||
break;
|
||||
case ProcessBookStatus.Failed:
|
||||
backColor = FailedColor;
|
||||
Status = ProcessBookStatus.Failed;
|
||||
break;
|
||||
}
|
||||
ProcessBookStatus.Completed => SuccessColor,
|
||||
ProcessBookStatus.Cancelled => CancelledColor,
|
||||
ProcessBookStatus.Queued => QueuedColor,
|
||||
ProcessBookStatus.Working => QueuedColor,
|
||||
_ => FailedColor
|
||||
};
|
||||
|
||||
SuspendLayout();
|
||||
|
||||
|
|
|
|||
|
|
@ -161,6 +161,8 @@ namespace LibationWinForms.ProcessQueue
|
|||
StartingTime = DateTime.Now;
|
||||
counterTimer.Start();
|
||||
|
||||
bool shownServiceOutageMessage = false;
|
||||
|
||||
while (Queue.MoveNext())
|
||||
{
|
||||
var nextBook = Queue.Current;
|
||||
|
|
@ -177,6 +179,18 @@ namespace LibationWinForms.ProcessQueue
|
|||
Queue.ClearQueue();
|
||||
else if (result == ProcessBookResult.FailedSkip)
|
||||
nextBook.LibraryBook.Book.UpdateBookStatus(DataLayer.LiberatedStatus.Error);
|
||||
else if (result == ProcessBookResult.LicenseDeniedPossibleOutage && !shownServiceOutageMessage)
|
||||
{
|
||||
MessageBox.Show(@$"
|
||||
You were denied a content license for {nextBook.LibraryBook.Book.Title}
|
||||
|
||||
This error appears to be caused by a temporary interruption of service that sometimes affects Libation's users. This type of error usually resolves itself in 1 to 2 days, and in the meantime you should still be able to access your books through Audible's website or app.
|
||||
",
|
||||
"Possible Interruption of Service",
|
||||
MessageBoxButtons.OK,
|
||||
MessageBoxIcon.Asterisk);
|
||||
shownServiceOutageMessage = true;
|
||||
}
|
||||
}
|
||||
Serilog.Log.Logger.Information("Completed processing queue");
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue