How to identify Error types in JavaScript?