Improved error handling for parsing errors

- Make string decoding tolerant to errors (for example the string might be cut down in the middle of an \x escape like \x1...)
- Add error handling to unformatter block so that errors can be diagnosed more easily