Added custom exception handling

Signed-off-by: Shonbir <shonbir.singh@gmail.com>