Add error handling in spreadsheet.js