Exception handling

Showing exception when server throws. Moved security check.