Rework exception handling to give invalid json