diff --git a/docs/labs/handling-errors.html b/docs/labs/handling-errors.html
index f4e276d6..6a628d83 100644
--- a/docs/labs/handling-errors.html
+++ b/docs/labs/handling-errors.html
@@ -83,7 +83,10 @@
- - " return { result: a / b };"
- index: 2
absent: '\s*try\s*{\s* '
- text: Use a try block to catch any exceptions that might be thrown.
+ text: >-
+ Use a try block to catch any exceptions that might be thrown.
+ It should look something like `try { ... } catch(err) {...}`
+ (fill in the `...` sections).
examples:
- - " const result = divide(10, 2);"
- index: 2
@@ -98,7 +101,9 @@
- - " try { const result = divide(10 ,2); console.log ( \"Result:\", result.result ); "
- index: 2
absent: '.*? catch .*? '
- text: Handle the error within the catch block.
+ text: >-
+ Handle the error within the catch block. You need `catch(err) {...}`
+ after `try {...}` to catch an error in the try block.
examples:
- - " try { const result = divide(10 ,2); console.log ( \"Result:\", result ); }"
- index: 2
@@ -107,10 +112,25 @@
examples:
- - " try { const result = divide(10 ,2); console.log ( \"Result:\", result ); } catch {}"
- index: 2
- absent: '\s* catch \s* \( err \) { \s* '
- text: Catch an object named err within the catch block.
+ absent: |-
+ catch \( err \)
+ text: >-
+ Please use `catch(err) {...}` for purposes of this lab.
examples:
- - " try { const result = divide(10 ,2); console.log ( \"Result:\", result ); } catch (foo) {"
+- index: 2
+ present: |-
+ catch .* console \. error \( ["'][^"']*["'] , result
+ text: >-
+ When reporting the error, you need to report it in the catch block,
+ which catches it as the variable `err`.
+ Thus, you need to use `err.message` not `result` or `result.message`,
+ since the error is in `err.message`. Note that
+ the variable `result` is out of scope in the catch block anyway;
+ it was declared in the try block.
+ examples:
+ - - " try { const result = divide(10 ,2); console.log ( \"Result:\", result ); } catch (err) { console.error('Error', result.message);"
+ - - " try { const result = divide(10 ,2); console.log ( \"Result:\", result ); } catch (err) { console.error('Error', result );"
# debug: true