From 9ce841b88003c8a4a9a9e0e06575c0ab53c13d37 Mon Sep 17 00:00:00 2001 From: Biarity Date: Wed, 14 Feb 2018 08:52:53 +1000 Subject: [PATCH 1/2] Added docs for optional exception handling (#7) --- README.md | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/README.md b/README.md index 2280584..6959c1e 100644 --- a/README.md +++ b/README.md @@ -100,15 +100,6 @@ public class SieveCustomFilterMethods : ISieveCustomFilterMethods } ``` -## Handle Sieve's exceptions - -Sieve can throw 2 kinds of custom exceptions: - -* `SieveMethodNotFoundException` with a `MethodName` -* `SieveIncompatibleMethodException` with a `MethodName`, an `ExpectedType` and an `ActualType` - -It is recommended that you write exception-handling middleware to globally handle Sieve's exceptions when using it with ASP.NET Core. - ## Configure Sieve Use the [ASP.NET Core options pattern](https://docs.microsoft.com/en-us/aspnet/core/fundamentals/configuration/options) with `SieveOptions` to tell Sieve where to look for configuration. For example: ``` @@ -119,11 +110,21 @@ Then you can add the configuration: { "Sieve": { "CaseSensitive": `boolean: should property names be case-sensitive? Defaults to false`, - "DefaultPageSize": `number: optional number to fallback to when no page argument is given` + "DefaultPageSize": `number: optional number to fallback to when no page argument is given. Set <=0 to disable paging if no pageSize is specified (default).`, + "ThrowExceptions": `boolean: should Sieve throw exceptions instead of silently failing? Defaults to false` } } ``` +## Handle Sieve's exceptions + +Sieve will silently fail unless `ThrowExceptions` in the configuration is set to true. 2 kinds of custom exceptions can be thrown: + +* `SieveMethodNotFoundException` with a `MethodName` +* `SieveIncompatibleMethodException` with a `MethodName`, an `ExpectedType` and an `ActualType` + +It is recommended that you write exception-handling middleware to globally handle Sieve's exceptions when using it with ASP.NET Core. + ## Send a request With all the above in place, you can now send a GET request that includes a sort/filter/page query. From 25d955a685625c59e1ab99ec811f39ba87ad0a95 Mon Sep 17 00:00:00 2001 From: Biarity Date: Wed, 14 Feb 2018 14:12:35 +1000 Subject: [PATCH 2/2] OR logic note (#8) --- README.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 6959c1e..5580f8c 100644 --- a/README.md +++ b/README.md @@ -150,7 +150,8 @@ More formally: Notes: * Don't forget to remove commas from any `{Value}` fields * You can have spaces anywhere except *within* `{Name}` or `{Operator}` fields -* Here's a [good example on how to work with arrays](https://github.com/Biarity/Sieve/issues/2) +* Here's a [good example on how to work with enumerables](https://github.com/Biarity/Sieve/issues/2) +* Another example on [how to do OR logic](https://github.com/Biarity/Sieve/issues/8) ### Creating your own DSL You can replace this DSL with your own (eg. use JSON instead) by implementing an [ISieveModel](https://github.com/Biarity/Sieve/blob/master/Sieve/Models/ISieveModel.cs). You can use the default [SieveModel](https://github.com/Biarity/Sieve/blob/master/Sieve/Models/SieveModel.cs) for reference.