Keep it Simple

// practice, the distance between dream and achievement

Tag: Exception (page 1 of 3)

Enterprise Library Logging

The Enterprise Library Logging Application Block allow you to create log messages and send those messages to different targets of output. The most typical output targets include a console window, file, database, web services and email though any conceivable target could be configured.

Logging Configuration has three major components

  1. Trace Source
    Trace sources act as the link between the log entries and the log targets.
  2. Trace Listener
    Trace listeners are responsible for taking the log entry, passing it through a separate log formatter and passing it to the target log.
  3. Log Formatter
    Log Formatter translates the content into a suitable format.

Continue reading

What really happens in a try – return – finally statement?

Have you ever wonder, what really happens in a try – return – finally statement? The finally statement is executed, but the return value isn’t affected. The execution order is:

  1. Code before return statement is executed
  2. Expression in return statement is evaluated
  3. finally block is executed
  4. Result evaluated in step#2 is returned

Continue reading

When should I use Try..Catch blocks?

In general, in today’s implementations, entering a try block is not expensive at all (this was not always true). However, throwing and handling an exception is usually an expensive operation. So, exceptions should only be used for exceptional events.

Refer this article for further details. In general, check will be cheap; processing the exception may not be.

Continue reading

Custom Exception

An exception is an error that occurs at runtime and terminates the normal flow of execution of a program if not handled properly. Exception handling is the technique of handling runtime errors in your application code. When exceptions occur, you may not want to reveal the actual stack trace or exception message to the user.

Custom exceptions can be used to customize the exception information or add meaningful information to your exceptions when they occur while the program is in execution.

Continue reading

Older posts

© 2017 Keep it Simple

Theme by Anders NorenUp ↑