jqgrid server exception error messages - jqgrid

Is there a way to show custom exception messages sent from the server in my jqGrid???? One of my function does a throws clause and throws some exception. I need to disoplay the error message relative to this thrown exception... Is there a way to do that in jqGrid???

You don't spectify in what jqGrid operation the exception could be throwen. There are different event handler which you can use to receive the text of the error message from the exception and decode it.
For example loadError(xhr,st,err) can be used to display the error messege which appears on the server during the loading of the jqGrid. I mean here the errors returned by the server on the ajax requests.
Additionally errorTextFormat(data) can be used to decode errors come up from the server during the ajax requests of the form editing. or errorfunc(rowid,res,stat) for the inline editing and errorCell(serverresponse,status) for cell editing.
So you can use the corresponding event handler functions in different places to decode the text of the exception message.

Related

uncaught exception : Experience not defined when testing a Shopify web app using Cypress

I'm writing automated tests for a Shopify application using cypress
When I finish filling the cart with items then click on the checkout button, I got this kind of error that prevents me to go to the checkout page :
(uncaught exception) Error: undefined status[500] response [{"message":"Experience not defined"}]
The following error originated from your application code, not from Cypress.It was caused by an unhandled promise rejection.
>undefined status[500] response [{"message":"Experience not defined"}]
When Cypress detects uncaught errors originated from your application it will automatically fail the current test.
This behavior is configurable, and you can choose to turn this off by listening to the uncaught:exception event.
This is the line when it heppens :
cy.get('.cart__checkout-form >
.button').scrollIntoView().click({force:true});

How to properly handle exception inside controller?

I am trying to upload a file. And if it throws an exception I don't want to see the "whoops" page. Instead it will go back the previous page with a message. This is what I tried,
try {
$data = Excel::toArray(new Import, request('file'));
} catch (\Exception $e) {
return back()->withErrors("an exception occured");
}
But it still gives me the whoops page whenever any exception occurs.
How to solve it?
Laravel 5.0 and up ships with an error handler at app/Exceptions/Handler.php. Here you can define a handler for any exception in your application. This way you don't need to add extra error handling in your controllers.
All information can be found in the documentation: https://laravel.com/docs/6.x/errors#the-exception-handler
I don't believe you will be able to catch/handle a Fatal Error. The script has stopped and is unrecoverable at this point. A shutdown handler is running as the script is shutting down. This is being handled by a shutdown function via register_shutdown_function.
Illuminate\Foundation\Bootstrap\HandleExceptions#handleShutdown will check to see if there was an error and if it was fatal and then pass a Symfony\Component\Debug\Exception\FatalErrorException to its own handler as an example.

MessageBoxShow on launch of the application

How to show the message box as soon as the application is launched.
I would like to add a welcome message in my application.
Eg:
MessageBox.Show("Welcome");
"Call the Show(String) method from the
OnNavigatedTo(NavigationEventArgs) method. If you call Show(String)
method from the app Activated and Launching event handlers an
InvalidOperationException is thrown with the message Error Displaying
MessageBox."
MSDN Source # http://msdn.microsoft.com/en-us/library/windowsphone/develop/jj206947(v=vs.105).aspx

Catching server side ajax handling errors in browser

Let's say I have some ajax based component, whose handler in server throws for some reason an exception (e.g. programming error, can't access database). And basically server responds with internal server error or some such. How can I catch this situation in browser and display for examplen an error message somewhere.
When user clicks this link, the server will show an error page and the browser should detect based on http status code that something went wrong and somehow to react to it.
new AjaxLink<Link>("link") {
public void onClick(AjaxRequestTarget target) {
throw new RuntimeException();
}
}
See org.apache.wicket.settings.IExceptionSettings#getAjaxErrorHandlingStrategy.
There is an example of this at http://www.wicket-library.com/wicket-examples/ajax/links (failure and exception links).
Normally, Wicket Ajax classes like AjaxFallbackLink for example, have a method
updateAjaxAttributes(AjaxRequestAttributes attributes)
where you can register error handlers, that execute javascript within the browser.
Override this method, create an AjaxCallListener and call
AjaxCallListener listener = new AjaxCallListener();
listener.onFailure(ADD_JAVASCRIPT_TO_EXECUTE_HERE);
attributes.getAjaxCallListeners().add(listener);
see the documentation of
org.apache.wicket.ajax.attributes.AjaxCallListener.getFailureHandler(Component component)

Windows Phone App crashes when using NavigationService.GoBack() too soon

Even though NavigationService.CanGoBack returns True, NavigationService.GoBack() throws me these exceptions :
A first chance exception of type 'System.ArgumentException' occurred in System.Windows.dll
A first chance exception of type 'System.Reflection.TargetInvocationException' occurred in
This happens systematically on two case, while the third works fine :
Crashes if I call NavigationService.GoBack() in OnNavigatedTo()
Crashes If I call NavigationService.GoBack() as a result of WebException thrown in my HTTPWebRequest when Internet is not available [1]
Works fine if Internet is available and I call NavigationService.GoBack() when my HTTPWebRequest got results, parsed them, and displayed them.
My theory is that I can't call GoBack() too soon after navigating from a page to another... My question : How can I programatically go back up the navigation stack when an HTTPWebRequest fails to load ?
Edit : I've decided to do it another way, but I think my problems might be due to navigation animations and the Windows Phone C# Toolkit (I use Feb 2011 edition)
[1] Details of my code on case 2 :
I have a simple HTTPWebRequest. My callback does this, and my app crashes when in Airplane Mode. The line NavigationService.GoBack() is responsible, even though NavigationService.CanGoBack returns true.
try
{
response = request.EndGetResponse(result);
}
catch (WebException)
{
Dispatcher.BeginInvoke(() =>
{
NavigationService.GoBack();
});
}
I tried using Deployment.Current.Dispatcher.BeginInvoke() also.
You could try using WebClient client = new WebClient();, then use client.DownloadStringAsync(new Uri("request_url")); to make your request and subscribe to the client.DownloadStringCompleted event to receive your data when the request is completed. After parsing the data, in the event handler you can then call NavigationService.GoBack(); or go to whichever page you want.
Also, if you try to do something in the OnNavigatedTo event and run into trouble you could try using the OnNavigatingFrom instead (on the previous page ofc), cancel the navigation e.Cancel = true;, do your thing as in make the request and stuff, then get the application frame and navigate to e.Uri (basically continuing the navigation you previously cancelled).
Altho this second might represent a solution as well, I think the first one is better as it does all the work async thus not blocking your UI thread. This is what I generally use in my apps. Hope it helps.

Resources