private static void Main() { PdfApi.ExceptionFactory = CustomExceptionFactory; BatchConversionHtml2PdfEx02().Wait(); Console.WriteLine("The conversion completed."); Console.ReadLine(); } private static async Task BatchConversionHtml2PdfEx02() { var res = StorageApi.GetListFiles(new GetListFilesRequest(FolderHTML, FirstStorage)); res.Files[0].Path = "badfile"; var tasks = res.Files.Select(item => PdfApi.PutCreateDocumentAsync( name: $"{Path.GetFileNameWithoutExtension(item.Name)}.pdf", templateFile: item.Path, templateType: "html", folder: "Pdf-Demo", storage: FirstStorage)); DocumentResponse[] documentResponses = null; try { documentResponses = await Task.WhenAll(tasks); } catch (AggregateException ex) { Console.WriteLine(ex.Message); } foreach (var documentResponse in documentResponses) { Console.WriteLine(documentResponse.Code); } } public static Exception CustomExceptionFactory(string methodName, RestSharp.IRestResponse response) { int status = (int)response.StatusCode; if (status >= 500) return new Aspose.Pdf.Cloud.Sdk.Client.ApiException(status, String.Format("Error calling {0}: {1}", methodName, response.Content), Newtonsoft.Json.Linq.JObject.Parse(response.Content)); if (status == 0) return new Aspose.Pdf.Cloud.Sdk.Client.ApiException(status, String.Format("Error calling {0}: {1}", methodName, response.ErrorMessage), response.ErrorMessage); return null; }