-
Notifications
You must be signed in to change notification settings - Fork 2.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Display query errors from ElasticSearch #16940
Draft
PBMikeW
wants to merge
14
commits into
OrchardCMS:main
Choose a base branch
from
PBMikeW:display-query-errors
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from all commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
7f6f9ab
Add switch statement and dynamic template for elastic geo_point field
PBMikeW aca563a
Merge branch 'main' into mikew/ElasticSearchGeoLocation
PBMikeW 29c7f5e
Update comment to better reflect where location is being set.
PBMikeW 17995f8
Remove unused model
PBMikeW 2e34f3c
Apply suggestions from code review
PBMikeW 1d64106
Merge branch 'main' into mikew/ElasticSearchGeoLocation
hishamco 33e6e3b
Merge branch 'main' into mikew/ElasticSearchGeoLocation
hishamco af7b2d8
Merge branch 'mikew/ElasticSearchGeoLocation'
PBMikeW f307cc9
Merge remote-tracking branch 'upstream/main'
PBMikeW c2021f8
Merge remote-tracking branch 'upstream/main'
PBMikeW d704411
Merge remote-tracking branch 'upstream/main'
PBMikeW 54cd28e
Merge branch 'main' into display-query-errors
PBMikeW 7562646
POC Working
PBMikeW 39661d8
Fix text errors (Async)
PBMikeW File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
43 changes: 43 additions & 0 deletions
43
src/OrchardCore/OrchardCore.Infrastructure/Filters/ApiExceptionHandlingFilter.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
using Microsoft.AspNetCore.Http; | ||
using Microsoft.AspNetCore.Mvc.Filters; | ||
using System.Text.Json; | ||
using Microsoft.AspNetCore.Mvc; | ||
using Microsoft.AspNetCore.Http.Json; | ||
using Json.More; | ||
namespace OrchardCore.Infrastructure.Filters; | ||
|
||
public class ApiExceptionHandlingFilter : IExceptionFilter | ||
{ | ||
private static readonly JsonSerializerOptions _jsonOptions = new() | ||
{ | ||
PropertyNamingPolicy = JsonNamingPolicy.CamelCase, | ||
WriteIndented = true | ||
}; | ||
|
||
public ApiExceptionHandlingFilter() | ||
{ | ||
|
||
} | ||
|
||
public void OnException(ExceptionContext context) | ||
{ | ||
var response = new ProblemDetails | ||
{ | ||
Type = "https://tools.ietf.org/html/rfc7231#section-6.6.1", | ||
Title = "An error occurred while processing your request.", | ||
Status = StatusCodes.Status500InternalServerError, | ||
Detail = context.Exception.Message, | ||
Instance = context.HttpContext.Request.Path | ||
}; | ||
|
||
context.HttpContext.Response.StatusCode = response.Status.Value; | ||
context.Result = new JsonResult(response, _jsonOptions); | ||
context.ExceptionHandled = true; | ||
} | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think I would use a 400 for this one.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We could also pass an error code along with the error string that we could document. Just to make a distinction between 500 and 400.