Added exception handling for libespm functions.