Better exception handling

Signed-off-by: Adam Dybbroe <adam.dybbroe@smhi.se>