+ All Categories
Home > Documents > Error Handling PDF

Error Handling PDF

Date post: 08-Apr-2018
Category:
Upload: dharmendra-singh-pinto
View: 244 times
Download: 0 times
Share this document with a friend

of 17

Transcript
  • 8/7/2019 Error Handling PDF

    1/17

    Error HandlingFindings from some researches and

    journals

    4/28/2011 1

  • 8/7/2019 Error Handling PDF

    2/17

    Error and ExceptionSome definitions:

    Error: A discrepancy between a computed, observed, or measuredvalue or condition and the true, specified, or theoretically correctvalue or condition.

    Failure: The inability of a system or component to perform itsrequired functions within specified performance requirements.

    Bug: A fault in a program which causes the program to perform inan unintended or unanticipated manner.

    Fault: An incorrect step, process, or data definition in a computer

    program which causes the program to perform in an unintended orunanticipated manner.

    Defect: Mismatch between the requirements.

    4/28/2011 2

  • 8/7/2019 Error Handling PDF

    3/17

    Error and Exception General perspective:

    An error is a mistake; something done wrong.

    Example: A printing or spelling error, for instance.

    An error of judgment (such as buying the wrong car).

    An error can be trivial or very grave, but it is always wrong.

    An exception is something that doesn't fit the usual rule

    (There is a common phrase, "The exception proves the rule.").

    This can apply to people or ideas

    Example: Nobody is allowed into a venue without a ticket, butthe doorman makes an exception of one person, i.e. lets themgo in free.

    4/28/2011 3

  • 8/7/2019 Error Handling PDF

    4/17

    Error and ExceptionTechnical perspective:

    Error:

    Any departure from the expected behavior of the system or program, which stopsthe working of the system, is an error.

    An undesired component that brings a system from a consistent state to aninconsistent state.

    Errors cannot be handled

    Error is unrecoverable:

    Example: OutOfMemoryError means that the JVM has no more memory to continue

    Exception: An exception is an event, which occurs during the execution of a program,that disrupts the normal flow of the program's instructions.

    An action that is not part of ordinary operations or standards

    An Exception can be caught and recovered:

    Examples : ArrayIndexOutOfBoundsException means you tried to access a position of anArray that does not exist - no big deal.

    Attempt to divide by zero etc.

    4/28/2011 4

  • 8/7/2019 Error Handling PDF

    5/17

    Error and Exception Kinds of Errors

    In any programming language there can be three kinds of errors.

    1. Syntax Errors

    The mistakes done while writing statements. For example, instead of "WRITE", if you type "WIRTE" it is a syntaxerror.

    Compiler can detect these types of errors. You will not be able to run the program till these errors are rectified.

    2. Runtime Errors (Exceptions)

    Runtime Errors are thrown when the situation occurs during execution of program where the system will not knowhow to deal with such situation.

    For example, You have done the program perfectly. No syntax errors. But while executing the program, if the userenters a filename that does not exist, the program will not know what to do next, at that time runtime erroroccurs. Runtime error terminates the execution of the program abruptly.

    Runtime errors mostly occur due to incorrect user entries or improper usage of system resources by program.

    These runtime errors can be avoided if we catch the exceptions.

    You can handle every possible exception and throw user defined messages during the execution and avoid abrupttermination of the program.

    3. Logical Errors

    Logical errors are obviously the mistake done in the logic by programmer.

    For example, Value = Rate - Discountis the normal universal calculation. By mistake if you have typed Value =Rate + Discount, it is neither syntax error nor runtime error. Your program is successful but result is wrong.

    This can be corrected only through thorough study of the program or worst case debugging.

    4/28/2011 5

  • 8/7/2019 Error Handling PDF

    6/17

    Error and Exception Kinds of Exceptions:

    1. Checked Exceptions: which have to be handled bythe code. These represent avoidable exceptionalconditions which can be handled and recovered from.

    2. Runtime Exceptions: which need not be handled bythe code. These represent unexpected exceptionalconditions which can be handled but not necessarilyrecover from.

    3. Errors: which need not be handled by the code.These represent severe unexpected exceptionalconditions which shud not be attempted to handle

    4/28/2011 6

  • 8/7/2019 Error Handling PDF

    7/17

    Error and ExceptionWhen to use the terms Error & Exception

    Use the term exception for expected but irregular situations at runtime and theterm error for mistakes in the running program, that can be resolved only by fixing

    the program.

    When exceptions become errors

    It is an error to not handle an exception. If a file cannot be opened you mustrespect that result. You can proceed as if the file could be opened, though. If you

    do so you might crash the machine or the runtime system terminates yourprogram. All of these effects are possible consequences of a (programming) error.Again, it does not matter whether the exceptional situation is signaled by a returncode that you ignore or an IO exception for which you did not run a catch

    When errors become exceptions

    Typical examples are: A process in an operating system shall not crash the wholesystem if it crashes itself. A buggy browser plugin shall not terminate the browser.A corrupt CGI script shall not bring the web server down, where it runs on.

    In these cases errors are handled like exceptions.

    4/28/2011 7

  • 8/7/2019 Error Handling PDF

    8/17

    Error v/s Exception

    Error Exception

    An Error is unrecoverable :

    OutOfMemoryError means that the JVM

    has no more memory to continue

    An Exception can be caught and

    recovered:

    ArrayIndexOutOfBoundsException means

    you tried to access a position of an Arraythat does not exist

    Any departure from the expected

    behavior of the system or program which

    stops the working of the system is an

    error

    Exception can be guessed and can be

    handled.

    4/28/2011 8

  • 8/7/2019 Error Handling PDF

    9/17

    Exception throwing and catching

    processCall Stack Searching the call stack for the exception

    handler

    4/28/2011 9

  • 8/7/2019 Error Handling PDF

    10/17

    Some common errors

    Un-validated Input

    Broken Access Control

    Broken Authentication and Session Management

    Cross-Site Scripting (XSS) Flaws

    Buffer Overflows

    Injection Flaws (Shell Commands and SQL)

    Improper Error Handling

    Insecure Storage

    Denial ofService

    Insecure Configuration Management

    Display of error messages Controls Management

    Database connection errors

    Dangling references and dead links.

    4/28/2011 10

  • 8/7/2019 Error Handling PDF

    11/17

    Errors related with web

    Bad request 400:This is a fairly common error and basically means that the requested document could not be sentbecause of syntax error in the URL (site address).

    Unauthorized 401:This is one of the most common error messages and usually means that the Server is expectingsome sort of encryption id from the browser (Mosaic, Netscape, etc) and when it does not receiveit, the server issues an error message.

    Forbidden 403:The document you are requesting is "forbidden" meaning that you do not have read privileges orare not allowed to have the page sent to you.

    Not found 404:This is the most common and is similar to the 400 error. Basically this means that the document youhave requested no longer exists or that the URL (site address) is incorrect.

    Internal Error 500:The server was unable to send the html document to you due to an internal (server software) error.

    Not implemented 501:This error occurs when for example, you have pressed the submit button on a form. The serverreplies with this error message because it doesn't support the feature that you have requested. Thisis not a real common error, but typically occurs when new features or forms are implemented.

    4/28/2011 11

  • 8/7/2019 Error Handling PDF

    12/17

    Exception Handling in Web Services

    Exception Handling for XMLQuery Execution Plans in a Web

    Service Environment

    Patrick C. K. Hung and Dickson K.W. Chiu2

    Senior Member,IEEE Faculty of Business and Information Technology, University

    of Ontario Institute of Technology, Canada .

    4/28/2011 12

  • 8/7/2019 Error Handling PDF

    13/17

    Exception Handling for Query

    Execution Plans

    Formulated XML and XQuery

    4/28/2011 13

  • 8/7/2019 Error Handling PDF

    14/17

    4/28/2011 14

  • 8/7/2019 Error Handling PDF

    15/17

    Exception Handling

    Tangling of try-catch blocks.

    Nesting of try-catch blocks.

    Dependency of exception handlers on localvariables.

    Placement of exception-throwing code

    Flow of control after handler execution.

    4/28/2011 15

  • 8/7/2019 Error Handling PDF

    16/17

    Handling

    4/28/2011 16

  • 8/7/2019 Error Handling PDF

    17/17

    Conclusion

    We should also note that exceptions are of two kinds:unchecked and checked.

    Detection and correction of errors is very important

    In case of web services we should be more carefulabout XML documents and XQuery.

    Security and privacy issues are serious concerns

    Considered only Loosely coupled and autonomousWeb services

    They are currently investigating other major securityproperties regarding the threats against confidentiality,integrity, anonymity and availability in the context ofWSEL

    4/28/2011 17


Recommended