So, I only passed this ticket because I threw in a return null as my piece of code to pass the test, purely so I could see the answer.
I was a little bit surprised how light lecture was on detail on what is a key part of development.
- Does catch(e) only ever contain an error message? For example on this ticket
“Error: Argument passed in must be a single String of 12 bytes or a string of 24 hex characters”
} catch (e) {
console.log(e.toString())
}
Since this only seemed on contain the error message.
-
Is there no way to grab a error code when mongoDB throws an exception. I was imaging an error object with codes and stuff to trap.
-
Does anyone know of any better pieces on the handling errors with a node/mongo code framework. More realistic pieces of code to hand issues when interfacing with Mongodb.
-
Finally why does using: -
npm test -t error-handling
Run
test/error-handling.test.js
and
test/lessons/writes-with-error-handling.spec.js
Is this an npm thing?