Which exception will be thrown by selenium when three elements are present with the same id and it tries to click on one of them?
Selenium won't throw any exception. it will locate the very first element and perform the action on that only
Related
The following adding the conditions have not worked so far:
!(Exception instanceof ReflectionException)
!(Exception instanceof \ReflectionException)
!(this instanceof ReflectionException)
!(this instanceof \ReflectionException)
!anInstanceOf(ReflectionException)
!anInstanceOf(\ReflectionException)
It still always breaks when a ReflectionException is thrown.
PhpStorm Documentation
There is no way, unfortunately.
A breakpoint condition is being sent to Xdebug within an eval command, so it has to be something that can actually be evaluated.
The Exception node in the PhpStorm's Variables pane, on the other hand, is received from Xdebug upon a break event once and can not be requested/evaluated further, so you can't put it into the condition.
So, it's either PhpStorm that should have an extra field in Exception Breakpoints that would check the Exception node contents, or Xdebug should have it possible to evaluate the exception somehow.
I'd say it's worth filing a feature request to us: https://youtrack.jetbrains.com/newIssue?project=WI
Is it possible to throw an exception in a Logic App?
Specifically, I'm trying to throw an exception inside of a scope. Then in the run after of the scope I'd check if it failed and inspect it for errors. I tried using a terminate inside of a scope, but that terminates the entire logic app run.
As an updated solution we can use Terminate control, Terminate control has 3 status: Failed, Canceled, and Succeeded.
Quick Answer (TL;DR)
Problem: MSFT Azure logic app throwing exceptions
Workaround: Use logic app Scope element to simulate throwing exceptions
Create a scope element to use as your "try-catch" block
Force the scope element to fail with an invalid command to simulate an exception
Allow the scope element to fail naturally and that will count as an exception too
Detailed Answer
Context
MSFT Azure logic app workflows
live version as of 2020-06-14
Problem
Scenario: Developer wishes to throw an exception or use try-catch semantics in a logic app
Solution
As of this writing, the live version of the product does not support this feature. There is a workaround.
Workaround
Use logic app scope element
add a conditional statement inside the scope element
If the conditional statement meets the failure condition, force an exception with a deliberately invalid command
for example create a variable assignment with the value int('__ERROR__')
If the conditional statement does not meet the failure condition, do nothing
The rest of the logic app consists of two paths
The first path runs on the success of the scope element
The second path runs on the failure of the scope element (failed, skipped, timed out)
Example
Create a scope element as a "try-catch" block
Create a variable compose element with an invalid command
int('__ERROR__') ## this will cause the enclosing scope to fail
## the string __ERROR__ cannot be cast to integer
Respond to exit status of the Scope element enclosing your exception
See also
related SO answer about forcing exceptions https://stackoverflow.com/a/61101945/42223
No, there is no Action or Connector directly analogous to something like a throw in C#.
The closest you can get right now would be to do something like use another LogicApp instead of a scope from which you can return a specific status code.
It seems like there still is no option for this inside Logic App or its little brother Power Automate / Microsoft Flow.
The way I have come up with and have used in some flows, is I simply add an action for something I know for a fact will fail.
The simplest (and probably the cheapest as the built-in actions cost less in Logic Apps, even if we are talking fractions of a dollar here either way) is probably to initialize a variable, e.g. called ThrowException with type of integer.
Then a "Set variable" action is added wherever I want my flow to fail, where I set the value (remember it is of type integer) to any string expression. I simply use the expression string('Exception').
Simple example screenshot
Since the value is set via an expression this is still a valid template, but will fail upon runtime when the value is actually being set.
After this, simply use parallel branches, with appropriate Run After settings, as usual.
In one of my projects I have a class that contains a lot of properties and a lot of interfaces. When the class is exposed using a Web API, the browser version displays the XML-serialized version of the class, which is okay. But when I use it in JavaScript, the JSON version is used and I get the NewtonSoft-related exception "An item with the same key has already been added." Because the XML-serialization does work, I assume it is caused by a duplicate class property name, but I do not know how to find the culprit.
My question is: How can I determine which class property causes this exception?
Is another thread modifying your structure while you serialize it? I observed DataContractJsonSerializer generate either "Collection was modified; enumeration operation may not execute." or just create a JSON with duplicate keys, which in turn generates "An item with the same key has already been added." when you try to read it.
In the EFContextProvider (EF6) SaveChangesCore method, the exception handling looks like this:
} catch (Exception e) {
while (e.InnerException != null) {
e = e.InnerException;
}
throw e;
}
This throws only the most internal exception and hides the relevant information revealed by the external exceptions.
When the SaveChanges process goes through multiple layers the next direct layer exception is lost, and only the last exception in the chain is thrown. It doesn't allow to handle well the exceptions for the caller.
Updated Post
As of Breeze 1.4.6, any .NET Exceptions thrown on the server are now available in their original form in the httpResponse.data property of any async breeze result. Breeze will still drill down to extract a "good" error message, but will no longer obscure the initial exception.
Original Post Below -------------------
It's an interesting point. The reason we did this was because most client side apps aren't written to navigate thru the exception chain and we wanted to expose the most 'relevant' error to the client. Most of the apps we looked at just exposed the client "error.message" property directly and with EF errors this was almost always useless.
However, your point is well taken. I think what we need to do is create a new Exception that has a top level message that is the innermost exception message but still expose the entire exception chain for those that want to drill. I've added an internal feature request for this and will try to get it into a near term release ( probably not the next one because we are already in testing for that one).
And thanks for the input.
I have a question about kohana exceptions.
I have a site that I want to put in production, and I don't want the exceptions to be simply thrown (like they are now), but I want to redirect the user to another page in case of an exception occured.
I use kohana 3, and I wonder: how can I catch an exception and redirect the user to another page if an exception happens:
example of code:
instead of
if ( ! $sale->loaded())
{
throw new Kohana_Request_Exception('Sale not found.');
}
I want: something like: page not found.
thank you!
What you'll need to do is register your own exception handler.
Take a look at the Error Handling documentation for an idea on what to do. Basically, you can capture any type of exception you want and do something specific with it (such as display a 404 page).