I'm running Symfony 4/5, and for all my controllers in order to be able to execute the method I have an EventSubscriber that checks for the right permissions.
If the user is not granted, then it throws an AccessDeniedHttpException.
This works fine as the method is binded to a route.
But when rendering inside a twig template manually a controller action as :
{{ render( controller('App\\ExampleBundle\\Controller\\ChartsController::renderChart' ) }}
I got a 500 error instead of a 403.
I've debugged the app and checked that the exception as actually thrown, but the browser shows a 500 exception.
Is this a bug, or do I have to handle in another way the exception when it is for manually rendered methods from a twig template ?
Related
I have a java project written using spring-cloud-function and deployed in aws-lambda.
I am trying to return a custom exception with some fields in the exception message body, something like"
{
reason: <exception reason>
code: <error code>
<some other fields>
}
#ExceptionHandler, that is generally used in spring boot doesn't seem to work here.
I can return the exception in the required format by creating a class for building the exception message in required format but in that case the error code will always be 200 since it will not be an exception object per se. Instead it will be my custom error object.
Is there a way I can set this up so that the above required format of exception object is returned and correct error code can be returned too?
Thanks in advance
First, the exception has nothing to do with Spring Boot. It's part of spring-web, so yes it would not work here since s-c-function is a general purpose framework, where the same function could be deployed and triggered via web, streaming, aws-lambda etc. .
Now, yes we had a problem returning JSON error (as you show) or object that represents the same, but that was fixed. So please update s-c-function to 3.2.3.
I'm on Prism Unity 8.1.97 with VS2022 and net6.0-windows project.
In my App.xaml.cs I registered a dialog like this inside RegisterTypes():
containerRegistry.RegisterDialog<MyDialog, MyViewModel>();
When the application tries to show the dialog like this:
_dialogService.ShowDialog("MyDialog", parameters, r => { });
I can see the following Debug output in Visual Studio but the debugger doesn't break so I get no info on the exception:
Exception thrown: 'Prism.Ioc.ContainerResolutionException' in Prism.Unity.Wpf.dll
I tried this in App.xaml.cs to get more info on the exception but the event handler doesn't seem to execute. Dialogs aren't modules?
While debugging the application, I can do the following and it returns a not null object:
_iocContainer.Resolve<object>("MyDialog")
How can I get access to the ContainerResolutionException details?
Why isn't this working anyway?
I have setup UseStatusCodePagesWithReExecute in asp.netcore website and it works fine.
I'm now trying to manually throw an error and I would like UseStatusCodePagesWithReExecute to catch it automatically but not as a 500 but as a 401 !
What type of exception should I throw?
If it's not possible, I guess I will have to create my custom middleware. In that case, how do I redirect from it in case I have this exception?
I am using RESTier 0.6.0 library and would like to perform some checks on a resource before deleting it. In the event that the checks fail, I am throwing an Exception to stop the delete operation. However, the error message that I am using to instantiate the Exception is not getting pushed out at the highest level. I can only view the message as an inner exception when serving my Web API from Visual Studio. Is there a way to get this error message to push out at the highest level?
protected void OnDeletingGw_Pack(Gw_Pack pack)
{
var trades = ModelContext.Gw_PackJunction.Where(e => e.PackID == pack.PackID).ToList();
if (pack.Groupage == true || trades.Count > 1)
{
// Don't delete a pack if it is a groupage container or if it's associated with more than one Trade.
throw new Exception("The container you are trying to delete is either marked as groupage or is functioning as a groupage container in another file.");
}
}
Currently any Exception thrown within the OnDelete submit logic methods in the EntityFrameworkApi results in an error which looks like this:
{
"error":{
"code":"","message":"An error has occurred."
}
}
... which is not particularly useful to the client.
UPDATE: I noted in the RESTier documentation MkDocs version that an example was given where an ODataException (rather than Exception) was thrown. I changed this in my code, but the error object returned by the published Restier service still only has the basic "An error has occurred" information.
Assistance is greatly appreciated!
When throwing an Exception within the RESTier EntityFrameworkApi (inside and OnUpdate<EntitySet> method for example), the exception is deserialized as part of the inner exception (internalexception). So in order to view any exceptions thrown within the RESTier API, one needs to...
set the IncludeErrorDetailPolicy property on the HttpConfiguration
class like this:
config.IncludeErrorDetailPolicy = IncludeErrorDetailPolicy.Always
Structure of error received by client
See this post: OData controller returns different error for local and different for remote machine
I stumbled upon a very weird issue in ColdFusion which might very well be a bug, but I wanted to post it here in case I was missing something.
It seems that cfindex is throwing an uncatchable exception when trying to index invalid files.
I'm not entirely sure yet what consists of an invalid file, but the issue occurs with a valid PDF file, but that doesn't have a PDF extension. Obviously, the problem can easily be fixed by adding a valid extension, but that's not the scope of the question.
<cftry>
<cfindex
collection="some_collection"
action="update"
key="//someserver/some_file_without_extension">
After index
<cfcatch type="any">
Exception caught
</cfcatch>
<cffinally>
Finally block
</cffinally>
</cftry>
Completed
When running the above code, the only thing that is output is Finally block, therefore it's like if there is an exception thrown, but which cannot be caught.
I even tried with type="java.lang.Exception", type="java.lang.Throwable" and type="searchengine" and nothing works.
The only way I found to detect such exceptions is to check a boolean flag in the finally block, but gracefully recovering form those errors is very cumbersome.
Another very weird thing that occurs is that right after the issue is encountered, if I refresh the page in the browser, I'll get the following error:
HTTP Error 503.0 - Server Error
The service is unavailable.
Module IsapiModule
Notification ExecuteRequestHandler
Handler JWildCardHandler
Error Code 0x00000000
Then after refreshing again, I get Finally block and if I keep refreshing the same behavior occurs over and over (Finally block then 503 error).