diff --git a/stuff/js/error-handling.js b/stuff/js/error-handling.js new file mode 100644 index 000000000..d95e1c057 --- /dev/null +++ b/stuff/js/error-handling.js @@ -0,0 +1,16 @@ +function logic() { + // ... + //throw new TypeError('data is not number') + throw new SyntaxError('data format is wrong') + // ... +} + +try { + logic() +} catch (error) { + if (error instanceof TypeError) + alert('WARN! type is not correct') + else if (error instanceof SyntaxError) + alert('FATAL! syntax is not correct') + +} \ No newline at end of file