TsLint: More cleanner error handling.
Fixes issues #455 and #456.