Added throw exception

Basic implementation of throw exception in library.