Added some code for handling errors in scala around <root>, needs test
Added some code for handling errors in scala around , needs test