Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Difference between error handling and exception handling
#1
Solved: 11 Years, 4 Months, 2 Weeks ago
Hi All,
Could you please explain with some sort of examples.....
If possible please provide some test data also.


Thanks,
Venkat.Batchu
Reply
#2
Solved: 11 Years, 4 Months, 2 Weeks ago
I'm not sure of the technical difference, but I believe they are just a difference in languages. VBScript/ASP is an Error object. Other languages that are object oriented (.NET, C++, Java) (3GL) use an exception object for errors.

VBScript example
Code:
on error resume next
a = 1/0
if err.number <> 0 then
  msgbox err.description
end if

VB.NET example
Code:
Try
  a=1/0
Catch (ex as exception)
  msgbox ex.message
End Try

C#
Code:
try
{
  a=1/0
}
catch (exception ex)
{
  msgbox ex.message
}

The exception is more powerful. It is also not dependent on the vague and often odd Microsoft Error codes to trigger a handle condition. For example, you can actually test for an exception of type System.IO.Exception instead of trying to case all the -214XXXXX error codes.

Hope this helps.
Reply
#3
Solved: 11 Years, 4 Months, 2 Weeks ago
Hi All,
with some R&D and am giving some of my understandings
Please let me know wheter this one is right or not

Error Handling means:

Which means we might be knowing where the error will comes in such situation we can handle those errors

Exception Handling means:
We will not be knowing when errors will come but using recovery scenario's we will be showing some of exceptions and this will be triggered whenver this exception will throws...


Please correct me if am wrong...

Thanks,
Venkat.Batchu
Reply
#4
Solved: 11 Years, 4 Months, 2 Weeks ago
hi venkatbatchu,
As per me we use error handling for expected error behavior of the application. Like in Flight reservation application, we have to validate that "If user click on OK button on Login dialog then error message(in dialog box- Please enter agent name) should display", same for 3 character error message and blank password and wrong password. We know that system should display that type of error. But we have to run our script for that we use error handling through (recovery scenario).
And we use exception handling for dynamic change in our application. Like Fax order. We also used to perform it through Regular expression.
Please let me know if i am worong?
I am not 100% sure for my ans. I request Ankur and Saket to look on this. This is very nice question.
Reply
#5
Solved: 11 Years, 4 Months, 2 Weeks ago
Error is an expected situation in your Script. For example, Consider a situation where you specified a divided by zero in your script logic, and the script throws an error. So you will need to handle this wherever your logic expects.
Where as exception is a runtime error that the AUT might encounter during the execution of your script.
For example you are trying to login into your application and application throws an error for database connectivity lost or something like Connection closed or license expired. These are exceptions which are unpredictable errors during runtime.

So in my opinion error handling is to put your logic to handle an expected error in your script and eception handling is to handle an unexpected error thrown by application /script at runtime.

Reply
#6
Solved: 11 Years, 4 Months, 2 Weeks ago
Hi ,

Here is the bottomline.

Predictable Errors --> Error handling ( By using "On Error Resume Next")
Unpredictable Errors --> Exception Handling (By using "[color]Recover Scenario Manager Wizard[/color]")
Reply
#7
Solved: 11 Years, 4 Months, 2 Weeks ago
Exceptions and Errors fall into three categories: checked exceptions, unchecked exceptions, and errors.

Checked Exceptions

Checked by the compiler at compile time
Methods that throw checked exceptions must indicate so with throws which must propagate up the calling stack until the exception is handled
Checked exceptions require explicit catching with a catch block
These include exceptions of the type Exception, except for RuntimeException and its subtypes

Unchecked Exceptions

Not checked at compile time by the compiler
Occur during runtime due to programmer error (i.e. out-of-bounds, divide by zero, etc.) or system resource exhaustion
These do not have to be caught (as they are not checked, they only are known when they occur)
Methods may throw unchecked exceptions but do not have to indicate so in declaration
These are exceptions and subtypes of RuntimeException

Errors

Errors are typically unrecoverable and present serious conditions
Errors are not checked at compile time and do not have to be (but can be) caught or handled
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Handling SSL certificates madhuri87 1 4,230 08-13-2015, 09:14 PM
Last Post: Ankur
  QTP hangs on handling error window dtamilarasan 1 3,848 06-04-2013, 02:45 PM
Last Post: basanth27
  Handling Object Repositories dynamically inside For Loop danny2012 3 4,122 07-13-2012, 02:00 PM
Last Post: danny2012
  Difference between "Set" and "Type" falvi 2 10,239 04-03-2012, 05:54 PM
Last Post: falvi
  Difference between RFT & QTP? SweetyChowdhury 18 20,799 08-26-2011, 07:43 AM
Last Post: nana1355

Forum Jump:


Users browsing this thread: 4 Guest(s)