Added exception handling to streamhandler