fix: new exception classes
This commit is contained in:
parent
d3c4be572b
commit
38444d5cd5
@ -4,6 +4,7 @@ using System.Threading.Tasks;
|
|||||||
using meilisearch.NET;
|
using meilisearch.NET;
|
||||||
using meilisearch.NET.Configurations;
|
using meilisearch.NET.Configurations;
|
||||||
using meilisearch.NET.example;
|
using meilisearch.NET.example;
|
||||||
|
using meilisearch.NET.Extensions;
|
||||||
using Microsoft.Extensions.Configuration;
|
using Microsoft.Extensions.Configuration;
|
||||||
using Microsoft.Extensions.DependencyInjection;
|
using Microsoft.Extensions.DependencyInjection;
|
||||||
using Microsoft.Extensions.Hosting;
|
using Microsoft.Extensions.Hosting;
|
||||||
|
12
meilisearch.NET/Exceptions/DocumentBatchException.cs
Normal file
12
meilisearch.NET/Exceptions/DocumentBatchException.cs
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
namespace meilisearch.NET.Exceptions;
|
||||||
|
|
||||||
|
public class DocumentBatchException : DocumentManagementException
|
||||||
|
{
|
||||||
|
public int BatchSize { get; }
|
||||||
|
|
||||||
|
public DocumentBatchException(int batchSize, Exception innerException)
|
||||||
|
: base($"Failed to process batch of {batchSize} documents", innerException)
|
||||||
|
{
|
||||||
|
BatchSize = batchSize;
|
||||||
|
}
|
||||||
|
}
|
10
meilisearch.NET/Exceptions/DocumentManagementException.cs
Normal file
10
meilisearch.NET/Exceptions/DocumentManagementException.cs
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
namespace meilisearch.NET.Exceptions;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Exception thrown when there are issues with document management
|
||||||
|
/// </summary>
|
||||||
|
public class DocumentManagementException : MeiliSearchException
|
||||||
|
{
|
||||||
|
public DocumentManagementException(string message) : base(message) { }
|
||||||
|
public DocumentManagementException(string message, Exception innerException) : base(message, innerException) { }
|
||||||
|
}
|
7
meilisearch.NET/Exceptions/DocumentSyncException.cs
Normal file
7
meilisearch.NET/Exceptions/DocumentSyncException.cs
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
namespace meilisearch.NET.Exceptions;
|
||||||
|
|
||||||
|
public class DocumentSyncException : DocumentManagementException
|
||||||
|
{
|
||||||
|
public DocumentSyncException(string message, Exception innerException)
|
||||||
|
: base($"Failed to sync documents: {message}", innerException) { }
|
||||||
|
}
|
@ -0,0 +1,7 @@
|
|||||||
|
namespace meilisearch.NET.Exceptions;
|
||||||
|
|
||||||
|
public class DocumentValidationException : DocumentManagementException
|
||||||
|
{
|
||||||
|
public DocumentValidationException(string message)
|
||||||
|
: base($"Document validation failed: {message}") { }
|
||||||
|
}
|
12
meilisearch.NET/Exceptions/IndexCompressionException.cs
Normal file
12
meilisearch.NET/Exceptions/IndexCompressionException.cs
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
namespace meilisearch.NET.Exceptions;
|
||||||
|
|
||||||
|
public class IndexCompressionException : IndexManagementException
|
||||||
|
{
|
||||||
|
public string IndexName { get; }
|
||||||
|
|
||||||
|
public IndexCompressionException(string indexName, string operation, Exception innerException)
|
||||||
|
: base($"Failed to {operation} index '{indexName}'", innerException)
|
||||||
|
{
|
||||||
|
IndexName = indexName;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,7 @@
|
|||||||
|
namespace meilisearch.NET.Exceptions;
|
||||||
|
|
||||||
|
public class IndexLimitExceededException : IndexManagementException
|
||||||
|
{
|
||||||
|
public IndexLimitExceededException()
|
||||||
|
: base("Maximum number of indexes (1000) has been reached") { }
|
||||||
|
}
|
10
meilisearch.NET/Exceptions/IndexManagementException.cs
Normal file
10
meilisearch.NET/Exceptions/IndexManagementException.cs
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
namespace meilisearch.NET.Exceptions;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Exception thrown when there are issues with index management
|
||||||
|
/// </summary>
|
||||||
|
public class IndexManagementException : MeiliSearchException
|
||||||
|
{
|
||||||
|
public IndexManagementException(string message) : base(message) { }
|
||||||
|
public IndexManagementException(string message, Exception innerException) : base(message, innerException) { }
|
||||||
|
}
|
12
meilisearch.NET/Exceptions/IndexNotFoundException.cs
Normal file
12
meilisearch.NET/Exceptions/IndexNotFoundException.cs
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
namespace meilisearch.NET.Exceptions;
|
||||||
|
|
||||||
|
public class IndexNotFoundException : IndexManagementException
|
||||||
|
{
|
||||||
|
public string IndexName { get; }
|
||||||
|
|
||||||
|
public IndexNotFoundException(string indexName)
|
||||||
|
: base($"Index '{indexName}' not found")
|
||||||
|
{
|
||||||
|
IndexName = indexName;
|
||||||
|
}
|
||||||
|
}
|
10
meilisearch.NET/Exceptions/MeiliSearchException.cs
Normal file
10
meilisearch.NET/Exceptions/MeiliSearchException.cs
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
namespace meilisearch.NET.Exceptions;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Base exception class for all Meilisearch.NET exceptions
|
||||||
|
/// </summary>
|
||||||
|
public class MeiliSearchException : Exception
|
||||||
|
{
|
||||||
|
public MeiliSearchException(string message) : base(message) { }
|
||||||
|
public MeiliSearchException(string message, Exception innerException) : base(message, innerException) { }
|
||||||
|
}
|
10
meilisearch.NET/Exceptions/ProcessManagementException.cs
Normal file
10
meilisearch.NET/Exceptions/ProcessManagementException.cs
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
namespace meilisearch.NET.Exceptions;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Exception thrown when there are issues with the Meilisearch process management
|
||||||
|
/// </summary>
|
||||||
|
public class ProcessManagementException : MeiliSearchException
|
||||||
|
{
|
||||||
|
public ProcessManagementException(string message) : base(message) { }
|
||||||
|
public ProcessManagementException(string message, Exception innerException) : base(message, innerException) { }
|
||||||
|
}
|
6
meilisearch.NET/Exceptions/ProcessNotRunningException.cs
Normal file
6
meilisearch.NET/Exceptions/ProcessNotRunningException.cs
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
namespace meilisearch.NET.Exceptions;
|
||||||
|
|
||||||
|
public class ProcessNotRunningException : ProcessManagementException
|
||||||
|
{
|
||||||
|
public ProcessNotRunningException() : base("Meilisearch process is not running") { }
|
||||||
|
}
|
6
meilisearch.NET/Exceptions/ProcessStartException.cs
Normal file
6
meilisearch.NET/Exceptions/ProcessStartException.cs
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
namespace meilisearch.NET.Exceptions;
|
||||||
|
|
||||||
|
public class ProcessStartException : ProcessManagementException
|
||||||
|
{
|
||||||
|
public ProcessStartException(string message) : base($"Failed to start Meilisearch process: {message}") { }
|
||||||
|
}
|
6
meilisearch.NET/Exceptions/ProcessStopException.cs
Normal file
6
meilisearch.NET/Exceptions/ProcessStopException.cs
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
namespace meilisearch.NET.Exceptions;
|
||||||
|
|
||||||
|
public class ProcessStopException : ProcessManagementException
|
||||||
|
{
|
||||||
|
public ProcessStopException(string message) : base($"Failed to stop Meilisearch process: {message}") { }
|
||||||
|
}
|
@ -1,6 +1,6 @@
|
|||||||
using Meilisearch;
|
using Meilisearch;
|
||||||
using meilisearch.NET;
|
|
||||||
using meilisearch.NET.Models;
|
namespace meilisearch.NET.Extensions;
|
||||||
|
|
||||||
public static class MeilisearchClientExtensions
|
public static class MeilisearchClientExtensions
|
||||||
{
|
{
|
||||||
|
@ -1,11 +1,12 @@
|
|||||||
using Meilisearch;
|
using Meilisearch;
|
||||||
using meilisearch.NET;
|
|
||||||
using meilisearch.NET.Configurations;
|
using meilisearch.NET.Configurations;
|
||||||
using meilisearch.NET.Services.DocumentManagement;
|
using meilisearch.NET.Services.DocumentManagement;
|
||||||
using meilisearch.NET.Services.IndexManagement;
|
using meilisearch.NET.Services.IndexManagement;
|
||||||
using meilisearch.NET.Services.ProcessManagement;
|
using meilisearch.NET.Services.ProcessManagement;
|
||||||
using Microsoft.Extensions.DependencyInjection;
|
using Microsoft.Extensions.DependencyInjection;
|
||||||
|
|
||||||
|
namespace meilisearch.NET.Extensions;
|
||||||
|
|
||||||
public static class ServiceCollectionExtension
|
public static class ServiceCollectionExtension
|
||||||
{
|
{
|
||||||
public static IServiceCollection AddMeiliSearchService(this IServiceCollection services)
|
public static IServiceCollection AddMeiliSearchService(this IServiceCollection services)
|
||||||
@ -22,4 +23,4 @@ public static class ServiceCollectionExtension
|
|||||||
services.AddSingleton<MeiliSearchService>();
|
services.AddSingleton<MeiliSearchService>();
|
||||||
return services;
|
return services;
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -29,7 +29,7 @@ public class DocumentManager:IDocumentManager
|
|||||||
_logger.LogInformation($"Document {document.Id} added to collection.");
|
_logger.LogInformation($"Document {document.Id} added to collection.");
|
||||||
if (autoCommit)
|
if (autoCommit)
|
||||||
{
|
{
|
||||||
SyncDocumentsToServer();
|
await SyncDocumentsToServerAsync();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
public void AddDocument(string repositoryId, IDocument document, bool autoCommit = false)
|
public void AddDocument(string repositoryId, IDocument document, bool autoCommit = false)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user