mirror of
https://github.com/claunia/marechai.git
synced 2026-07-08 17:57:08 +00:00
refactor: standardize error handling by extracting detailed messages from ApiException
This commit is contained in:
@@ -153,7 +153,7 @@ public sealed class CollectionService(Client client, ILogger<CollectionService>
|
||||
{
|
||||
logger.LogError(ex, "API error adding book {BookId} to collection", bookId);
|
||||
|
||||
return (false, ex.Message);
|
||||
return (false, ExtractDetail(ex));
|
||||
}
|
||||
catch(Exception ex)
|
||||
{
|
||||
@@ -175,7 +175,7 @@ public sealed class CollectionService(Client client, ILogger<CollectionService>
|
||||
{
|
||||
logger.LogError(ex, "API error removing book {BookId} from collection", bookId);
|
||||
|
||||
return (false, ex.Message);
|
||||
return (false, ExtractDetail(ex));
|
||||
}
|
||||
catch(Exception ex)
|
||||
{
|
||||
@@ -215,7 +215,7 @@ public sealed class CollectionService(Client client, ILogger<CollectionService>
|
||||
{
|
||||
logger.LogError(ex, "API error adding document {DocumentId} to collection", documentId);
|
||||
|
||||
return (false, ex.Message);
|
||||
return (false, ExtractDetail(ex));
|
||||
}
|
||||
catch(Exception ex)
|
||||
{
|
||||
@@ -237,7 +237,7 @@ public sealed class CollectionService(Client client, ILogger<CollectionService>
|
||||
{
|
||||
logger.LogError(ex, "API error removing document {DocumentId} from collection", documentId);
|
||||
|
||||
return (false, ex.Message);
|
||||
return (false, ExtractDetail(ex));
|
||||
}
|
||||
catch(Exception ex)
|
||||
{
|
||||
@@ -277,7 +277,7 @@ public sealed class CollectionService(Client client, ILogger<CollectionService>
|
||||
{
|
||||
logger.LogError(ex, "API error adding machine {MachineId} to collection", machineId);
|
||||
|
||||
return (false, ex.Message);
|
||||
return (false, ExtractDetail(ex));
|
||||
}
|
||||
catch(Exception ex)
|
||||
{
|
||||
@@ -299,7 +299,7 @@ public sealed class CollectionService(Client client, ILogger<CollectionService>
|
||||
{
|
||||
logger.LogError(ex, "API error removing machine {MachineId} from collection", machineId);
|
||||
|
||||
return (false, ex.Message);
|
||||
return (false, ExtractDetail(ex));
|
||||
}
|
||||
catch(Exception ex)
|
||||
{
|
||||
@@ -339,7 +339,7 @@ public sealed class CollectionService(Client client, ILogger<CollectionService>
|
||||
{
|
||||
logger.LogError(ex, "API error adding software release {ReleaseId} to collection", releaseId);
|
||||
|
||||
return (false, ex.Message);
|
||||
return (false, ExtractDetail(ex));
|
||||
}
|
||||
catch(Exception ex)
|
||||
{
|
||||
@@ -361,7 +361,7 @@ public sealed class CollectionService(Client client, ILogger<CollectionService>
|
||||
{
|
||||
logger.LogError(ex, "API error removing software release {ReleaseId} from collection", releaseId);
|
||||
|
||||
return (false, ex.Message);
|
||||
return (false, ExtractDetail(ex));
|
||||
}
|
||||
catch(Exception ex)
|
||||
{
|
||||
@@ -401,7 +401,7 @@ public sealed class CollectionService(Client client, ILogger<CollectionService>
|
||||
{
|
||||
logger.LogError(ex, "API error adding magazine issue {IssueId} to collection", issueId);
|
||||
|
||||
return (false, ex.Message);
|
||||
return (false, ExtractDetail(ex));
|
||||
}
|
||||
catch(Exception ex)
|
||||
{
|
||||
@@ -423,7 +423,7 @@ public sealed class CollectionService(Client client, ILogger<CollectionService>
|
||||
{
|
||||
logger.LogError(ex, "API error removing magazine issue {IssueId} from collection", issueId);
|
||||
|
||||
return (false, ex.Message);
|
||||
return (false, ExtractDetail(ex));
|
||||
}
|
||||
catch(Exception ex)
|
||||
{
|
||||
@@ -431,5 +431,19 @@ public sealed class CollectionService(Client client, ILogger<CollectionService>
|
||||
|
||||
return (false, ex.Message);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
static string ExtractDetail(ApiException ex)
|
||||
{
|
||||
if(ex is ProblemDetails pd)
|
||||
{
|
||||
if(!string.IsNullOrWhiteSpace(pd.Detail)) return pd.Detail;
|
||||
if(!string.IsNullOrWhiteSpace(pd.Title)) return pd.Title;
|
||||
}
|
||||
|
||||
if(ex is { ResponseStatusCode: 0 } || string.IsNullOrWhiteSpace(ex.Message)) return "Unknown error";
|
||||
|
||||
return ex.Message;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -109,8 +109,8 @@ public class CompaniesService(Marechai.ApiClient.Client client, ReferenceDataCac
|
||||
return (id, null);
|
||||
}
|
||||
catch(ApiException ex)
|
||||
{
|
||||
return (null, ex.Message);
|
||||
{
|
||||
return (null, ExtractDetail(ex));
|
||||
}
|
||||
catch(Exception ex)
|
||||
{
|
||||
@@ -129,8 +129,8 @@ public class CompaniesService(Marechai.ApiClient.Client client, ReferenceDataCac
|
||||
return (true, null);
|
||||
}
|
||||
catch(ApiException ex)
|
||||
{
|
||||
return (false, ex.Message);
|
||||
{
|
||||
return (false, ExtractDetail(ex));
|
||||
}
|
||||
catch(Exception ex)
|
||||
{
|
||||
@@ -147,8 +147,8 @@ public class CompaniesService(Marechai.ApiClient.Client client, ReferenceDataCac
|
||||
return (true, null);
|
||||
}
|
||||
catch(ApiException ex)
|
||||
{
|
||||
return (false, ex.Message);
|
||||
{
|
||||
return (false, ExtractDetail(ex));
|
||||
}
|
||||
catch(Exception ex)
|
||||
{
|
||||
@@ -231,8 +231,8 @@ public class CompaniesService(Marechai.ApiClient.Client client, ReferenceDataCac
|
||||
return (true, null);
|
||||
}
|
||||
catch(ApiException ex)
|
||||
{
|
||||
return (false, ex.Message);
|
||||
{
|
||||
return (false, ExtractDetail(ex));
|
||||
}
|
||||
catch(Exception ex)
|
||||
{
|
||||
@@ -249,8 +249,8 @@ public class CompaniesService(Marechai.ApiClient.Client client, ReferenceDataCac
|
||||
return (true, null);
|
||||
}
|
||||
catch(ApiException ex)
|
||||
{
|
||||
return (false, ex.Message);
|
||||
{
|
||||
return (false, ExtractDetail(ex));
|
||||
}
|
||||
catch(Exception ex)
|
||||
{
|
||||
@@ -464,13 +464,24 @@ public class CompaniesService(Marechai.ApiClient.Client client, ReferenceDataCac
|
||||
}
|
||||
catch(ApiException ex)
|
||||
{
|
||||
string detail = ex is ProblemDetails pd ? pd.Detail ?? pd.Title ?? ex.Message : ex.Message;
|
||||
|
||||
return (false, detail);
|
||||
return (false, ExtractDetail(ex));
|
||||
}
|
||||
catch(Exception ex)
|
||||
{
|
||||
return (false, ex.Message);
|
||||
}
|
||||
}
|
||||
|
||||
static string ExtractDetail(ApiException ex)
|
||||
{
|
||||
if(ex is ProblemDetails pd)
|
||||
{
|
||||
if(!string.IsNullOrWhiteSpace(pd.Detail)) return pd.Detail;
|
||||
if(!string.IsNullOrWhiteSpace(pd.Title)) return pd.Title;
|
||||
}
|
||||
|
||||
if(ex is { ResponseStatusCode: 0 } || string.IsNullOrWhiteSpace(ex.Message)) return "Unknown error";
|
||||
|
||||
return ex.Message;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -105,6 +105,10 @@ public class GpuPhotosService(Marechai.ApiClient.Client client, IRequestAdapter
|
||||
|
||||
return (result, null);
|
||||
}
|
||||
catch(ApiException ex)
|
||||
{
|
||||
return (null, ExtractDetail(ex));
|
||||
}
|
||||
catch(Exception ex)
|
||||
{
|
||||
return (null, ex.Message);
|
||||
@@ -119,6 +123,10 @@ public class GpuPhotosService(Marechai.ApiClient.Client client, IRequestAdapter
|
||||
|
||||
return (true, null);
|
||||
}
|
||||
catch(ApiException ex)
|
||||
{
|
||||
return (false, ExtractDetail(ex));
|
||||
}
|
||||
catch(Exception ex)
|
||||
{
|
||||
return (false, ex.Message);
|
||||
@@ -180,6 +188,10 @@ public class GpuPhotosService(Marechai.ApiClient.Client client, IRequestAdapter
|
||||
await client.Gpus.Photos.Admin.Batch.Commit.PostAsync(request);
|
||||
return (job, null);
|
||||
}
|
||||
catch(ApiException ex)
|
||||
{
|
||||
return (null, ExtractDetail(ex));
|
||||
}
|
||||
catch(Exception ex)
|
||||
{
|
||||
return (null, ex.Message);
|
||||
@@ -201,5 +213,19 @@ public class GpuPhotosService(Marechai.ApiClient.Client client, IRequestAdapter
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
static string ExtractDetail(ApiException ex)
|
||||
{
|
||||
if(ex is ProblemDetails pd)
|
||||
{
|
||||
if(!string.IsNullOrWhiteSpace(pd.Detail)) return pd.Detail;
|
||||
if(!string.IsNullOrWhiteSpace(pd.Title)) return pd.Title;
|
||||
}
|
||||
|
||||
if(ex is { ResponseStatusCode: 0 } || string.IsNullOrWhiteSpace(ex.Message)) return "Unknown error";
|
||||
|
||||
return ex.Message;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -148,7 +148,7 @@ public class GpusService(Marechai.ApiClient.Client client, IndexNowService index
|
||||
}
|
||||
catch(ApiException ex)
|
||||
{
|
||||
return (null, ExtractErrorMessage(ex));
|
||||
return (null, ExtractDetail(ex));
|
||||
}
|
||||
catch(Exception ex)
|
||||
{
|
||||
@@ -168,7 +168,7 @@ public class GpusService(Marechai.ApiClient.Client client, IndexNowService index
|
||||
}
|
||||
catch(ApiException ex)
|
||||
{
|
||||
return (false, ExtractErrorMessage(ex));
|
||||
return (false, ExtractDetail(ex));
|
||||
}
|
||||
catch(Exception ex)
|
||||
{
|
||||
@@ -186,7 +186,7 @@ public class GpusService(Marechai.ApiClient.Client client, IndexNowService index
|
||||
}
|
||||
catch(ApiException ex)
|
||||
{
|
||||
return (false, ExtractErrorMessage(ex));
|
||||
return (false, ExtractDetail(ex));
|
||||
}
|
||||
catch(Exception ex)
|
||||
{
|
||||
@@ -233,7 +233,7 @@ public class GpusService(Marechai.ApiClient.Client client, IndexNowService index
|
||||
}
|
||||
catch(ApiException ex)
|
||||
{
|
||||
return (null, ExtractErrorMessage(ex));
|
||||
return (null, ExtractDetail(ex));
|
||||
}
|
||||
catch(Exception ex)
|
||||
{
|
||||
@@ -251,7 +251,7 @@ public class GpusService(Marechai.ApiClient.Client client, IndexNowService index
|
||||
}
|
||||
catch(ApiException ex)
|
||||
{
|
||||
return (false, ExtractErrorMessage(ex));
|
||||
return (false, ExtractDetail(ex));
|
||||
}
|
||||
catch(Exception ex)
|
||||
{
|
||||
@@ -362,7 +362,7 @@ public class GpusService(Marechai.ApiClient.Client client, IndexNowService index
|
||||
}
|
||||
catch(ApiException ex)
|
||||
{
|
||||
return (false, ExtractErrorMessage(ex));
|
||||
return (false, ExtractDetail(ex));
|
||||
}
|
||||
catch(Exception ex)
|
||||
{
|
||||
@@ -380,7 +380,7 @@ public class GpusService(Marechai.ApiClient.Client client, IndexNowService index
|
||||
}
|
||||
catch(ApiException ex)
|
||||
{
|
||||
return (false, ExtractErrorMessage(ex));
|
||||
return (false, ExtractDetail(ex));
|
||||
}
|
||||
catch(Exception ex)
|
||||
{
|
||||
@@ -390,12 +390,6 @@ public class GpusService(Marechai.ApiClient.Client client, IndexNowService index
|
||||
|
||||
// ── Videos ──
|
||||
|
||||
static string ExtractErrorMessage(ApiException ex)
|
||||
{
|
||||
if(ex is ProblemDetails pd) return pd.Detail ?? pd.Title ?? ex.Message;
|
||||
|
||||
return ex.Message;
|
||||
}
|
||||
|
||||
public async Task<List<GpuVideoDto>> GetVideosByGpuAsync(int gpuId)
|
||||
{
|
||||
@@ -429,7 +423,7 @@ public class GpusService(Marechai.ApiClient.Client client, IndexNowService index
|
||||
}
|
||||
catch(ApiException ex)
|
||||
{
|
||||
return (null, ExtractErrorMessage(ex));
|
||||
return (null, ExtractDetail(ex));
|
||||
}
|
||||
catch(Exception ex)
|
||||
{
|
||||
@@ -450,7 +444,7 @@ public class GpusService(Marechai.ApiClient.Client client, IndexNowService index
|
||||
}
|
||||
catch(ApiException ex)
|
||||
{
|
||||
return (false, ExtractErrorMessage(ex));
|
||||
return (false, ExtractDetail(ex));
|
||||
}
|
||||
catch(Exception ex)
|
||||
{
|
||||
@@ -468,11 +462,25 @@ public class GpusService(Marechai.ApiClient.Client client, IndexNowService index
|
||||
}
|
||||
catch(ApiException ex)
|
||||
{
|
||||
return (false, ExtractErrorMessage(ex));
|
||||
return (false, ExtractDetail(ex));
|
||||
}
|
||||
catch(Exception ex)
|
||||
{
|
||||
return (false, ex.Message);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
static string ExtractDetail(ApiException ex)
|
||||
{
|
||||
if(ex is ProblemDetails pd)
|
||||
{
|
||||
if(!string.IsNullOrWhiteSpace(pd.Detail)) return pd.Detail;
|
||||
if(!string.IsNullOrWhiteSpace(pd.Title)) return pd.Title;
|
||||
}
|
||||
|
||||
if(ex is { ResponseStatusCode: 0 } || string.IsNullOrWhiteSpace(ex.Message)) return "Unknown error";
|
||||
|
||||
return ex.Message;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -68,8 +68,8 @@ public class InstructionSetsService(Marechai.ApiClient.Client client)
|
||||
return (id, null);
|
||||
}
|
||||
catch(ApiException ex)
|
||||
{
|
||||
return (null, ex.Message);
|
||||
{
|
||||
return (null, ExtractDetail(ex));
|
||||
}
|
||||
catch(Exception ex)
|
||||
{
|
||||
@@ -86,8 +86,8 @@ public class InstructionSetsService(Marechai.ApiClient.Client client)
|
||||
return (true, null);
|
||||
}
|
||||
catch(ApiException ex)
|
||||
{
|
||||
return (false, ex.Message);
|
||||
{
|
||||
return (false, ExtractDetail(ex));
|
||||
}
|
||||
catch(Exception ex)
|
||||
{
|
||||
@@ -104,8 +104,8 @@ public class InstructionSetsService(Marechai.ApiClient.Client client)
|
||||
return (true, null);
|
||||
}
|
||||
catch(ApiException ex)
|
||||
{
|
||||
return (false, ex.Message);
|
||||
{
|
||||
return (false, ExtractDetail(ex));
|
||||
}
|
||||
catch(Exception ex)
|
||||
{
|
||||
@@ -125,5 +125,19 @@ public class InstructionSetsService(Marechai.ApiClient.Client client)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
static string ExtractDetail(ApiException ex)
|
||||
{
|
||||
if(ex is ProblemDetails pd)
|
||||
{
|
||||
if(!string.IsNullOrWhiteSpace(pd.Detail)) return pd.Detail;
|
||||
if(!string.IsNullOrWhiteSpace(pd.Title)) return pd.Title;
|
||||
}
|
||||
|
||||
if(ex is { ResponseStatusCode: 0 } || string.IsNullOrWhiteSpace(ex.Message)) return "Unknown error";
|
||||
|
||||
return ex.Message;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -105,6 +105,10 @@ public class MachinePhotosService(Marechai.ApiClient.Client client, IRequestAdap
|
||||
|
||||
return (result, null);
|
||||
}
|
||||
catch(ApiException ex)
|
||||
{
|
||||
return (null, ExtractDetail(ex));
|
||||
}
|
||||
catch(Exception ex)
|
||||
{
|
||||
return (null, ex.Message);
|
||||
@@ -119,6 +123,10 @@ public class MachinePhotosService(Marechai.ApiClient.Client client, IRequestAdap
|
||||
|
||||
return (true, null);
|
||||
}
|
||||
catch(ApiException ex)
|
||||
{
|
||||
return (false, ExtractDetail(ex));
|
||||
}
|
||||
catch(Exception ex)
|
||||
{
|
||||
return (false, ex.Message);
|
||||
@@ -192,6 +200,10 @@ public class MachinePhotosService(Marechai.ApiClient.Client client, IRequestAdap
|
||||
await client.Machines.Photos.Admin.Batch.Commit.PostAsync(request);
|
||||
return (job, null);
|
||||
}
|
||||
catch(ApiException ex)
|
||||
{
|
||||
return (null, ExtractDetail(ex));
|
||||
}
|
||||
catch(Exception ex)
|
||||
{
|
||||
return (null, ex.Message);
|
||||
@@ -213,5 +225,19 @@ public class MachinePhotosService(Marechai.ApiClient.Client client, IRequestAdap
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
static string ExtractDetail(ApiException ex)
|
||||
{
|
||||
if(ex is ProblemDetails pd)
|
||||
{
|
||||
if(!string.IsNullOrWhiteSpace(pd.Detail)) return pd.Detail;
|
||||
if(!string.IsNullOrWhiteSpace(pd.Title)) return pd.Title;
|
||||
}
|
||||
|
||||
if(ex is { ResponseStatusCode: 0 } || string.IsNullOrWhiteSpace(ex.Message)) return "Unknown error";
|
||||
|
||||
return ex.Message;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -35,12 +35,6 @@ namespace Marechai.Services;
|
||||
|
||||
public class MachinesService(Marechai.ApiClient.Client client, IndexNowService indexNow)
|
||||
{
|
||||
static string ExtractErrorMessage(ApiException ex)
|
||||
{
|
||||
if(ex is ProblemDetails pd) return pd.Detail ?? pd.Title ?? ex.Message;
|
||||
|
||||
return ex.Message;
|
||||
}
|
||||
public async Task<MachineDto> GetMachine(int id)
|
||||
{
|
||||
try
|
||||
@@ -139,8 +133,8 @@ public class MachinesService(Marechai.ApiClient.Client client, IndexNowService i
|
||||
return (id, null);
|
||||
}
|
||||
catch(ApiException ex)
|
||||
{
|
||||
return (null, ex.Message);
|
||||
{
|
||||
return (null, ExtractDetail(ex));
|
||||
}
|
||||
catch(Exception ex)
|
||||
{
|
||||
@@ -159,8 +153,8 @@ public class MachinesService(Marechai.ApiClient.Client client, IndexNowService i
|
||||
return (true, null);
|
||||
}
|
||||
catch(ApiException ex)
|
||||
{
|
||||
return (false, ex.Message);
|
||||
{
|
||||
return (false, ExtractDetail(ex));
|
||||
}
|
||||
catch(Exception ex)
|
||||
{
|
||||
@@ -177,8 +171,8 @@ public class MachinesService(Marechai.ApiClient.Client client, IndexNowService i
|
||||
return (true, null);
|
||||
}
|
||||
catch(ApiException ex)
|
||||
{
|
||||
return (false, ex.Message);
|
||||
{
|
||||
return (false, ExtractDetail(ex));
|
||||
}
|
||||
catch(Exception ex)
|
||||
{
|
||||
@@ -264,8 +258,8 @@ public class MachinesService(Marechai.ApiClient.Client client, IndexNowService i
|
||||
return (id, null);
|
||||
}
|
||||
catch(ApiException ex)
|
||||
{
|
||||
return (null, ex.Message);
|
||||
{
|
||||
return (null, ExtractDetail(ex));
|
||||
}
|
||||
catch(Exception ex)
|
||||
{
|
||||
@@ -282,8 +276,8 @@ public class MachinesService(Marechai.ApiClient.Client client, IndexNowService i
|
||||
return (true, null);
|
||||
}
|
||||
catch(ApiException ex)
|
||||
{
|
||||
return (false, ex.Message);
|
||||
{
|
||||
return (false, ExtractDetail(ex));
|
||||
}
|
||||
catch(Exception ex)
|
||||
{
|
||||
@@ -329,8 +323,8 @@ public class MachinesService(Marechai.ApiClient.Client client, IndexNowService i
|
||||
return (id, null);
|
||||
}
|
||||
catch(ApiException ex)
|
||||
{
|
||||
return (null, ex.Message);
|
||||
{
|
||||
return (null, ExtractDetail(ex));
|
||||
}
|
||||
catch(Exception ex)
|
||||
{
|
||||
@@ -347,8 +341,8 @@ public class MachinesService(Marechai.ApiClient.Client client, IndexNowService i
|
||||
return (true, null);
|
||||
}
|
||||
catch(ApiException ex)
|
||||
{
|
||||
return (false, ex.Message);
|
||||
{
|
||||
return (false, ExtractDetail(ex));
|
||||
}
|
||||
catch(Exception ex)
|
||||
{
|
||||
@@ -394,8 +388,8 @@ public class MachinesService(Marechai.ApiClient.Client client, IndexNowService i
|
||||
return (id, null);
|
||||
}
|
||||
catch(ApiException ex)
|
||||
{
|
||||
return (null, ex.Message);
|
||||
{
|
||||
return (null, ExtractDetail(ex));
|
||||
}
|
||||
catch(Exception ex)
|
||||
{
|
||||
@@ -412,8 +406,8 @@ public class MachinesService(Marechai.ApiClient.Client client, IndexNowService i
|
||||
return (true, null);
|
||||
}
|
||||
catch(ApiException ex)
|
||||
{
|
||||
return (false, ex.Message);
|
||||
{
|
||||
return (false, ExtractDetail(ex));
|
||||
}
|
||||
catch(Exception ex)
|
||||
{
|
||||
@@ -459,8 +453,8 @@ public class MachinesService(Marechai.ApiClient.Client client, IndexNowService i
|
||||
return (id, null);
|
||||
}
|
||||
catch(ApiException ex)
|
||||
{
|
||||
return (null, ex.Message);
|
||||
{
|
||||
return (null, ExtractDetail(ex));
|
||||
}
|
||||
catch(Exception ex)
|
||||
{
|
||||
@@ -477,8 +471,8 @@ public class MachinesService(Marechai.ApiClient.Client client, IndexNowService i
|
||||
return (true, null);
|
||||
}
|
||||
catch(ApiException ex)
|
||||
{
|
||||
return (false, ex.Message);
|
||||
{
|
||||
return (false, ExtractDetail(ex));
|
||||
}
|
||||
catch(Exception ex)
|
||||
{
|
||||
@@ -510,8 +504,8 @@ public class MachinesService(Marechai.ApiClient.Client client, IndexNowService i
|
||||
return (id, null);
|
||||
}
|
||||
catch(ApiException ex)
|
||||
{
|
||||
return (null, ex.Message);
|
||||
{
|
||||
return (null, ExtractDetail(ex));
|
||||
}
|
||||
catch(Exception ex)
|
||||
{
|
||||
@@ -528,8 +522,8 @@ public class MachinesService(Marechai.ApiClient.Client client, IndexNowService i
|
||||
return (true, null);
|
||||
}
|
||||
catch(ApiException ex)
|
||||
{
|
||||
return (false, ex.Message);
|
||||
{
|
||||
return (false, ExtractDetail(ex));
|
||||
}
|
||||
catch(Exception ex)
|
||||
{
|
||||
@@ -561,8 +555,8 @@ public class MachinesService(Marechai.ApiClient.Client client, IndexNowService i
|
||||
return (id, null);
|
||||
}
|
||||
catch(ApiException ex)
|
||||
{
|
||||
return (null, ex.Message);
|
||||
{
|
||||
return (null, ExtractDetail(ex));
|
||||
}
|
||||
catch(Exception ex)
|
||||
{
|
||||
@@ -579,8 +573,8 @@ public class MachinesService(Marechai.ApiClient.Client client, IndexNowService i
|
||||
return (true, null);
|
||||
}
|
||||
catch(ApiException ex)
|
||||
{
|
||||
return (false, ex.Message);
|
||||
{
|
||||
return (false, ExtractDetail(ex));
|
||||
}
|
||||
catch(Exception ex)
|
||||
{
|
||||
@@ -684,8 +678,8 @@ public class MachinesService(Marechai.ApiClient.Client client, IndexNowService i
|
||||
return (id, null);
|
||||
}
|
||||
catch(ApiException ex)
|
||||
{
|
||||
return (null, ex.Message);
|
||||
{
|
||||
return (null, ExtractDetail(ex));
|
||||
}
|
||||
catch(Exception ex)
|
||||
{
|
||||
@@ -702,8 +696,8 @@ public class MachinesService(Marechai.ApiClient.Client client, IndexNowService i
|
||||
return (true, null);
|
||||
}
|
||||
catch(ApiException ex)
|
||||
{
|
||||
return (false, ex.Message);
|
||||
{
|
||||
return (false, ExtractDetail(ex));
|
||||
}
|
||||
catch(Exception ex)
|
||||
{
|
||||
@@ -773,8 +767,8 @@ public class MachinesService(Marechai.ApiClient.Client client, IndexNowService i
|
||||
return (true, null);
|
||||
}
|
||||
catch(ApiException ex)
|
||||
{
|
||||
return (false, ex.Message);
|
||||
{
|
||||
return (false, ExtractDetail(ex));
|
||||
}
|
||||
catch(Exception ex)
|
||||
{
|
||||
@@ -791,8 +785,8 @@ public class MachinesService(Marechai.ApiClient.Client client, IndexNowService i
|
||||
return (true, null);
|
||||
}
|
||||
catch(ApiException ex)
|
||||
{
|
||||
return (false, ex.Message);
|
||||
{
|
||||
return (false, ExtractDetail(ex));
|
||||
}
|
||||
catch(Exception ex)
|
||||
{
|
||||
@@ -834,7 +828,7 @@ public class MachinesService(Marechai.ApiClient.Client client, IndexNowService i
|
||||
}
|
||||
catch(ApiException ex)
|
||||
{
|
||||
return (null, ExtractErrorMessage(ex));
|
||||
return (null, ExtractDetail(ex));
|
||||
}
|
||||
catch(Exception ex)
|
||||
{
|
||||
@@ -855,7 +849,7 @@ public class MachinesService(Marechai.ApiClient.Client client, IndexNowService i
|
||||
}
|
||||
catch(ApiException ex)
|
||||
{
|
||||
return (false, ExtractErrorMessage(ex));
|
||||
return (false, ExtractDetail(ex));
|
||||
}
|
||||
catch(Exception ex)
|
||||
{
|
||||
@@ -873,11 +867,25 @@ public class MachinesService(Marechai.ApiClient.Client client, IndexNowService i
|
||||
}
|
||||
catch(ApiException ex)
|
||||
{
|
||||
return (false, ExtractErrorMessage(ex));
|
||||
return (false, ExtractDetail(ex));
|
||||
}
|
||||
catch(Exception ex)
|
||||
{
|
||||
return (false, ex.Message);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
static string ExtractDetail(ApiException ex)
|
||||
{
|
||||
if(ex is ProblemDetails pd)
|
||||
{
|
||||
if(!string.IsNullOrWhiteSpace(pd.Detail)) return pd.Detail;
|
||||
if(!string.IsNullOrWhiteSpace(pd.Title)) return pd.Title;
|
||||
}
|
||||
|
||||
if(ex is { ResponseStatusCode: 0 } || string.IsNullOrWhiteSpace(ex.Message)) return "Unknown error";
|
||||
|
||||
return ex.Message;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -362,5 +362,19 @@ public class MessagingService(Marechai.ApiClient.Client client)
|
||||
{
|
||||
return (false, ex.Message);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
static string ExtractDetail(ApiException ex)
|
||||
{
|
||||
if(ex is ProblemDetails pd)
|
||||
{
|
||||
if(!string.IsNullOrWhiteSpace(pd.Detail)) return pd.Detail;
|
||||
if(!string.IsNullOrWhiteSpace(pd.Title)) return pd.Title;
|
||||
}
|
||||
|
||||
if(ex is { ResponseStatusCode: 0 } || string.IsNullOrWhiteSpace(ex.Message)) return "Unknown error";
|
||||
|
||||
return ex.Message;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -105,6 +105,10 @@ public class ProcessorPhotosService(Marechai.ApiClient.Client client, IRequestAd
|
||||
|
||||
return (result, null);
|
||||
}
|
||||
catch(ApiException ex)
|
||||
{
|
||||
return (null, ExtractDetail(ex));
|
||||
}
|
||||
catch(Exception ex)
|
||||
{
|
||||
return (null, ex.Message);
|
||||
@@ -119,6 +123,10 @@ public class ProcessorPhotosService(Marechai.ApiClient.Client client, IRequestAd
|
||||
|
||||
return (true, null);
|
||||
}
|
||||
catch(ApiException ex)
|
||||
{
|
||||
return (false, ExtractDetail(ex));
|
||||
}
|
||||
catch(Exception ex)
|
||||
{
|
||||
return (false, ex.Message);
|
||||
@@ -180,6 +188,10 @@ public class ProcessorPhotosService(Marechai.ApiClient.Client client, IRequestAd
|
||||
await client.Processors.Photos.Admin.Batch.Commit.PostAsync(request);
|
||||
return (job, null);
|
||||
}
|
||||
catch(ApiException ex)
|
||||
{
|
||||
return (null, ExtractDetail(ex));
|
||||
}
|
||||
catch(Exception ex)
|
||||
{
|
||||
return (null, ex.Message);
|
||||
@@ -201,5 +213,19 @@ public class ProcessorPhotosService(Marechai.ApiClient.Client client, IRequestAd
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
static string ExtractDetail(ApiException ex)
|
||||
{
|
||||
if(ex is ProblemDetails pd)
|
||||
{
|
||||
if(!string.IsNullOrWhiteSpace(pd.Detail)) return pd.Detail;
|
||||
if(!string.IsNullOrWhiteSpace(pd.Title)) return pd.Title;
|
||||
}
|
||||
|
||||
if(ex is { ResponseStatusCode: 0 } || string.IsNullOrWhiteSpace(ex.Message)) return "Unknown error";
|
||||
|
||||
return ex.Message;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -147,8 +147,8 @@ public class ProcessorsService(Marechai.ApiClient.Client client, IndexNowService
|
||||
return (id, null);
|
||||
}
|
||||
catch(ApiException ex)
|
||||
{
|
||||
return (null, ex.Message);
|
||||
{
|
||||
return (null, ExtractDetail(ex));
|
||||
}
|
||||
catch(Exception ex)
|
||||
{
|
||||
@@ -167,8 +167,8 @@ public class ProcessorsService(Marechai.ApiClient.Client client, IndexNowService
|
||||
return (true, null);
|
||||
}
|
||||
catch(ApiException ex)
|
||||
{
|
||||
return (false, ex.Message);
|
||||
{
|
||||
return (false, ExtractDetail(ex));
|
||||
}
|
||||
catch(Exception ex)
|
||||
{
|
||||
@@ -185,8 +185,8 @@ public class ProcessorsService(Marechai.ApiClient.Client client, IndexNowService
|
||||
return (true, null);
|
||||
}
|
||||
catch(ApiException ex)
|
||||
{
|
||||
return (false, ex.Message);
|
||||
{
|
||||
return (false, ExtractDetail(ex));
|
||||
}
|
||||
catch(Exception ex)
|
||||
{
|
||||
@@ -285,8 +285,8 @@ public class ProcessorsService(Marechai.ApiClient.Client client, IndexNowService
|
||||
return (id, null);
|
||||
}
|
||||
catch(ApiException ex)
|
||||
{
|
||||
return (null, ex.Message);
|
||||
{
|
||||
return (null, ExtractDetail(ex));
|
||||
}
|
||||
catch(Exception ex)
|
||||
{
|
||||
@@ -303,8 +303,8 @@ public class ProcessorsService(Marechai.ApiClient.Client client, IndexNowService
|
||||
return (true, null);
|
||||
}
|
||||
catch(ApiException ex)
|
||||
{
|
||||
return (false, ex.Message);
|
||||
{
|
||||
return (false, ExtractDetail(ex));
|
||||
}
|
||||
catch(Exception ex)
|
||||
{
|
||||
@@ -374,8 +374,8 @@ public class ProcessorsService(Marechai.ApiClient.Client client, IndexNowService
|
||||
return (true, null);
|
||||
}
|
||||
catch(ApiException ex)
|
||||
{
|
||||
return (false, ex.Message);
|
||||
{
|
||||
return (false, ExtractDetail(ex));
|
||||
}
|
||||
catch(Exception ex)
|
||||
{
|
||||
@@ -392,8 +392,8 @@ public class ProcessorsService(Marechai.ApiClient.Client client, IndexNowService
|
||||
return (true, null);
|
||||
}
|
||||
catch(ApiException ex)
|
||||
{
|
||||
return (false, ex.Message);
|
||||
{
|
||||
return (false, ExtractDetail(ex));
|
||||
}
|
||||
catch(Exception ex)
|
||||
{
|
||||
@@ -487,5 +487,19 @@ public class ProcessorsService(Marechai.ApiClient.Client client, IndexNowService
|
||||
{
|
||||
return (false, ex.Message);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
static string ExtractDetail(ApiException ex)
|
||||
{
|
||||
if(ex is ProblemDetails pd)
|
||||
{
|
||||
if(!string.IsNullOrWhiteSpace(pd.Detail)) return pd.Detail;
|
||||
if(!string.IsNullOrWhiteSpace(pd.Title)) return pd.Title;
|
||||
}
|
||||
|
||||
if(ex is { ResponseStatusCode: 0 } || string.IsNullOrWhiteSpace(ex.Message)) return "Unknown error";
|
||||
|
||||
return ex.Message;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -243,5 +243,19 @@ public class SoftwareAttributesService(Marechai.ApiClient.Client client)
|
||||
{
|
||||
return (null, ex.Message);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
static string ExtractDetail(ApiException ex)
|
||||
{
|
||||
if(ex is ProblemDetails pd)
|
||||
{
|
||||
if(!string.IsNullOrWhiteSpace(pd.Detail)) return pd.Detail;
|
||||
if(!string.IsNullOrWhiteSpace(pd.Title)) return pd.Title;
|
||||
}
|
||||
|
||||
if(ex is { ResponseStatusCode: 0 } || string.IsNullOrWhiteSpace(ex.Message)) return "Unknown error";
|
||||
|
||||
return ex.Message;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -83,8 +83,8 @@ public class SoftwareReleasesService(Marechai.ApiClient.Client client, Reference
|
||||
return (id, null);
|
||||
}
|
||||
catch(ApiException ex)
|
||||
{
|
||||
return (null, ex.Message);
|
||||
{
|
||||
return (null, ExtractDetail(ex));
|
||||
}
|
||||
catch(Exception ex)
|
||||
{
|
||||
@@ -101,8 +101,8 @@ public class SoftwareReleasesService(Marechai.ApiClient.Client client, Reference
|
||||
return (true, null);
|
||||
}
|
||||
catch(ApiException ex)
|
||||
{
|
||||
return (false, ex.Message);
|
||||
{
|
||||
return (false, ExtractDetail(ex));
|
||||
}
|
||||
catch(Exception ex)
|
||||
{
|
||||
@@ -119,8 +119,8 @@ public class SoftwareReleasesService(Marechai.ApiClient.Client client, Reference
|
||||
return (true, null);
|
||||
}
|
||||
catch(ApiException ex)
|
||||
{
|
||||
return (false, ex.Message);
|
||||
{
|
||||
return (false, ExtractDetail(ex));
|
||||
}
|
||||
catch(Exception ex)
|
||||
{
|
||||
@@ -154,8 +154,8 @@ public class SoftwareReleasesService(Marechai.ApiClient.Client client, Reference
|
||||
return (id, null);
|
||||
}
|
||||
catch(ApiException ex)
|
||||
{
|
||||
return (null, ex.Message);
|
||||
{
|
||||
return (null, ExtractDetail(ex));
|
||||
}
|
||||
catch(Exception ex)
|
||||
{
|
||||
@@ -172,8 +172,8 @@ public class SoftwareReleasesService(Marechai.ApiClient.Client client, Reference
|
||||
return (true, null);
|
||||
}
|
||||
catch(ApiException ex)
|
||||
{
|
||||
return (false, ex.Message);
|
||||
{
|
||||
return (false, ExtractDetail(ex));
|
||||
}
|
||||
catch(Exception ex)
|
||||
{
|
||||
@@ -207,8 +207,8 @@ public class SoftwareReleasesService(Marechai.ApiClient.Client client, Reference
|
||||
return (id, null);
|
||||
}
|
||||
catch(ApiException ex)
|
||||
{
|
||||
return (null, ex.Message);
|
||||
{
|
||||
return (null, ExtractDetail(ex));
|
||||
}
|
||||
catch(Exception ex)
|
||||
{
|
||||
@@ -225,8 +225,8 @@ public class SoftwareReleasesService(Marechai.ApiClient.Client client, Reference
|
||||
return (true, null);
|
||||
}
|
||||
catch(ApiException ex)
|
||||
{
|
||||
return (false, ex.Message);
|
||||
{
|
||||
return (false, ExtractDetail(ex));
|
||||
}
|
||||
catch(Exception ex)
|
||||
{
|
||||
@@ -260,8 +260,8 @@ public class SoftwareReleasesService(Marechai.ApiClient.Client client, Reference
|
||||
return (true, null);
|
||||
}
|
||||
catch(ApiException ex)
|
||||
{
|
||||
return (false, ex.Message);
|
||||
{
|
||||
return (false, ExtractDetail(ex));
|
||||
}
|
||||
catch(Exception ex)
|
||||
{
|
||||
@@ -278,8 +278,8 @@ public class SoftwareReleasesService(Marechai.ApiClient.Client client, Reference
|
||||
return (true, null);
|
||||
}
|
||||
catch(ApiException ex)
|
||||
{
|
||||
return (false, ex.Message);
|
||||
{
|
||||
return (false, ExtractDetail(ex));
|
||||
}
|
||||
catch(Exception ex)
|
||||
{
|
||||
@@ -313,8 +313,8 @@ public class SoftwareReleasesService(Marechai.ApiClient.Client client, Reference
|
||||
return (true, null);
|
||||
}
|
||||
catch(ApiException ex)
|
||||
{
|
||||
return (false, ex.Message);
|
||||
{
|
||||
return (false, ExtractDetail(ex));
|
||||
}
|
||||
catch(Exception ex)
|
||||
{
|
||||
@@ -331,8 +331,8 @@ public class SoftwareReleasesService(Marechai.ApiClient.Client client, Reference
|
||||
return (true, null);
|
||||
}
|
||||
catch(ApiException ex)
|
||||
{
|
||||
return (false, ex.Message);
|
||||
{
|
||||
return (false, ExtractDetail(ex));
|
||||
}
|
||||
catch(Exception ex)
|
||||
{
|
||||
@@ -366,8 +366,8 @@ public class SoftwareReleasesService(Marechai.ApiClient.Client client, Reference
|
||||
return (true, null);
|
||||
}
|
||||
catch(ApiException ex)
|
||||
{
|
||||
return (false, ex.Message);
|
||||
{
|
||||
return (false, ExtractDetail(ex));
|
||||
}
|
||||
catch(Exception ex)
|
||||
{
|
||||
@@ -384,8 +384,8 @@ public class SoftwareReleasesService(Marechai.ApiClient.Client client, Reference
|
||||
return (true, null);
|
||||
}
|
||||
catch(ApiException ex)
|
||||
{
|
||||
return (false, ex.Message);
|
||||
{
|
||||
return (false, ExtractDetail(ex));
|
||||
}
|
||||
catch(Exception ex)
|
||||
{
|
||||
@@ -547,8 +547,8 @@ public class SoftwareReleasesService(Marechai.ApiClient.Client client, Reference
|
||||
return (true, null);
|
||||
}
|
||||
catch(ApiException ex)
|
||||
{
|
||||
return (false, ex.Message);
|
||||
{
|
||||
return (false, ExtractDetail(ex));
|
||||
}
|
||||
catch(Exception ex)
|
||||
{
|
||||
@@ -565,8 +565,8 @@ public class SoftwareReleasesService(Marechai.ApiClient.Client client, Reference
|
||||
return (true, null);
|
||||
}
|
||||
catch(ApiException ex)
|
||||
{
|
||||
return (false, ex.Message);
|
||||
{
|
||||
return (false, ExtractDetail(ex));
|
||||
}
|
||||
catch(Exception ex)
|
||||
{
|
||||
@@ -760,8 +760,8 @@ public class SoftwareReleasesService(Marechai.ApiClient.Client client, Reference
|
||||
return (true, null);
|
||||
}
|
||||
catch(ApiException ex)
|
||||
{
|
||||
return (false, ex.Message);
|
||||
{
|
||||
return (false, ExtractDetail(ex));
|
||||
}
|
||||
catch(Exception ex)
|
||||
{
|
||||
@@ -778,8 +778,8 @@ public class SoftwareReleasesService(Marechai.ApiClient.Client client, Reference
|
||||
return (true, null);
|
||||
}
|
||||
catch(ApiException ex)
|
||||
{
|
||||
return (false, ex.Message);
|
||||
{
|
||||
return (false, ExtractDetail(ex));
|
||||
}
|
||||
catch(Exception ex)
|
||||
{
|
||||
@@ -911,7 +911,7 @@ public class SoftwareReleasesService(Marechai.ApiClient.Client client, Reference
|
||||
}
|
||||
catch(ApiException ex)
|
||||
{
|
||||
return (null, ex is ProblemDetails pd ? (pd.Detail ?? pd.Title ?? ex.Message) : ex.Message);
|
||||
return (null, ExtractDetail(ex));
|
||||
}
|
||||
catch(Exception ex)
|
||||
{
|
||||
@@ -934,5 +934,19 @@ public class SoftwareReleasesService(Marechai.ApiClient.Client client, Reference
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
static string ExtractDetail(ApiException ex)
|
||||
{
|
||||
if(ex is ProblemDetails pd)
|
||||
{
|
||||
if(!string.IsNullOrWhiteSpace(pd.Detail)) return pd.Detail;
|
||||
if(!string.IsNullOrWhiteSpace(pd.Title)) return pd.Title;
|
||||
}
|
||||
|
||||
if(ex is { ResponseStatusCode: 0 } || string.IsNullOrWhiteSpace(ex.Message)) return "Unknown error";
|
||||
|
||||
return ex.Message;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2431,5 +2431,19 @@ public class SoftwareService(Marechai.ApiClient.Client client, IRequestAdapter r
|
||||
{
|
||||
return (false, ex.Message);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
static string ExtractDetail(ApiException ex)
|
||||
{
|
||||
if(ex is ProblemDetails pd)
|
||||
{
|
||||
if(!string.IsNullOrWhiteSpace(pd.Detail)) return pd.Detail;
|
||||
if(!string.IsNullOrWhiteSpace(pd.Title)) return pd.Title;
|
||||
}
|
||||
|
||||
if(ex is { ResponseStatusCode: 0 } || string.IsNullOrWhiteSpace(ex.Message)) return "Unknown error";
|
||||
|
||||
return ex.Message;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -105,6 +105,10 @@ public class SoundSynthPhotosService(Marechai.ApiClient.Client client, IRequestA
|
||||
|
||||
return (result, null);
|
||||
}
|
||||
catch(ApiException ex)
|
||||
{
|
||||
return (null, ExtractDetail(ex));
|
||||
}
|
||||
catch(Exception ex)
|
||||
{
|
||||
return (null, ex.Message);
|
||||
@@ -119,6 +123,10 @@ public class SoundSynthPhotosService(Marechai.ApiClient.Client client, IRequestA
|
||||
|
||||
return (true, null);
|
||||
}
|
||||
catch(ApiException ex)
|
||||
{
|
||||
return (false, ExtractDetail(ex));
|
||||
}
|
||||
catch(Exception ex)
|
||||
{
|
||||
return (false, ex.Message);
|
||||
@@ -180,6 +188,10 @@ public class SoundSynthPhotosService(Marechai.ApiClient.Client client, IRequestA
|
||||
await client.SoundSynths.Photos.Admin.Batch.Commit.PostAsync(request);
|
||||
return (job, null);
|
||||
}
|
||||
catch(ApiException ex)
|
||||
{
|
||||
return (null, ExtractDetail(ex));
|
||||
}
|
||||
catch(Exception ex)
|
||||
{
|
||||
return (null, ex.Message);
|
||||
@@ -201,5 +213,19 @@ public class SoundSynthPhotosService(Marechai.ApiClient.Client client, IRequestA
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
static string ExtractDetail(ApiException ex)
|
||||
{
|
||||
if(ex is ProblemDetails pd)
|
||||
{
|
||||
if(!string.IsNullOrWhiteSpace(pd.Detail)) return pd.Detail;
|
||||
if(!string.IsNullOrWhiteSpace(pd.Title)) return pd.Title;
|
||||
}
|
||||
|
||||
if(ex is { ResponseStatusCode: 0 } || string.IsNullOrWhiteSpace(ex.Message)) return "Unknown error";
|
||||
|
||||
return ex.Message;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -399,5 +399,19 @@ public class SoundSynthsService(Marechai.ApiClient.Client client, IndexNowServic
|
||||
{
|
||||
return (false, ex.Message);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
static string ExtractDetail(ApiException ex)
|
||||
{
|
||||
if(ex is ProblemDetails pd)
|
||||
{
|
||||
if(!string.IsNullOrWhiteSpace(pd.Detail)) return pd.Detail;
|
||||
if(!string.IsNullOrWhiteSpace(pd.Title)) return pd.Title;
|
||||
}
|
||||
|
||||
if(ex is { ResponseStatusCode: 0 } || string.IsNullOrWhiteSpace(ex.Message)) return "Unknown error";
|
||||
|
||||
return ex.Message;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user