Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ namespace QueryKit.Exceptions;

public sealed class ParsingException : Exception
{
public ParsingException(Exception exception)
public ParsingException(Exception exception)
: base($"There was a parsing failure, likely due to an invalid comparison or logical operator. You may also be missing double quotes surrounding a string or guid.", exception)
{
}
Expand Down
4 changes: 2 additions & 2 deletions QueryKit/Exceptions/QueryKitDbContextTypeException.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
namespace QueryKit.Exceptions;

public sealed class QueryKitDbContextTypeException : Exception
public sealed class QueryKitDbContextTypeException : QueryKitException
{
public QueryKitDbContextTypeException(string specificMessage)
public QueryKitDbContextTypeException(string specificMessage)
: base($"There no DbContext type provided in your QueryKit config, but one was needed for this operation. {specificMessage}")
{
}
Expand Down
10 changes: 10 additions & 0 deletions QueryKit/Exceptions/QueryKitException.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
namespace QueryKit.Exceptions;

/// <summary>
/// Base QueryKit exception, all exceptions thrown by QueryKit inherit this.
/// </summary>
public class QueryKitException : Exception
{
public QueryKitException(string message, Exception exception) : base(message, exception) {}
public QueryKitException(string message) : base(message) {}
}
4 changes: 2 additions & 2 deletions QueryKit/Exceptions/QueryKitParsingException.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
namespace QueryKit.Exceptions;

public sealed class QueryKitParsingException : Exception
public sealed class QueryKitParsingException : QueryKitException
{
public QueryKitParsingException(string message)
public QueryKitParsingException(string message)
: base(message)
{
}
Expand Down
4 changes: 2 additions & 2 deletions QueryKit/Exceptions/SortParsingException.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
namespace QueryKit.Exceptions;

public sealed class SortParsingException : Exception
public sealed class SortParsingException : QueryKitException
{
public SortParsingException(string propertyName)
public SortParsingException(string propertyName)
: base($"Parsing failed during sorting. '{propertyName}' was not recognized.")
{
}
Expand Down
4 changes: 2 additions & 2 deletions QueryKit/Exceptions/SoundsLikeNotImplementedException.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
namespace QueryKit.Exceptions;

public sealed class SoundsLikeNotImplementedException : Exception
public sealed class SoundsLikeNotImplementedException : QueryKitException
{
public SoundsLikeNotImplementedException(string dbContextType)
public SoundsLikeNotImplementedException(string dbContextType)
: base($"The DbContext type {dbContextType} does not have a SoundsLike method.")
{
}
Expand Down
4 changes: 2 additions & 2 deletions QueryKit/Exceptions/UnknownFilterPropertyException.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
namespace QueryKit.Exceptions;

public sealed class UnknownFilterPropertyException : Exception
public sealed class UnknownFilterPropertyException : QueryKitException
{
public UnknownFilterPropertyException(string propertyName)
public UnknownFilterPropertyException(string propertyName)
: base($"The filter property '{propertyName}' was not recognized.")
{
}
Expand Down
6 changes: 4 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -419,7 +419,9 @@ var people = _dbContext.People

If you want to capture errors to easily throw a `400`, you can add error handling around these exceptions:

* A `FilterParsingException` will be thrown when there is an invalid operator or bad syntax is used (e.g. not using double quotes around a string or guid).
* A `QueryKitException` is the base class for all of the exceptions listed below. This can be caught to catch
any exception thrown by QueryKit.
* A `ParsingException` will be thrown when there is an invalid operator or bad syntax is used (e.g. not using double quotes around a string or guid).
* An `UnknownFilterPropertyException` will be thrown if a property is not recognized during filtering
* A `SortParsingException` will be thrown if a property or operation is not recognized during sorting
* A `QueryKitDbContextTypeException` will be thrown when trying to use a `DbContext` specific workflow without passing that context (e.g. SoundEx)
Expand Down Expand Up @@ -477,4 +479,4 @@ var people = await appliedQueryable.ToListAsync();
```

## Community Projects
- [Fluent QueryKit](https://github.com/CLFPosthumus/fluent-querykit) for easy usage in javascript or typescript projects.
- [Fluent QueryKit](https://github.com/CLFPosthumus/fluent-querykit) for easy usage in javascript or typescript projects.