Welcome to the Linux Foundation Forum!

More issues with lab exercises

sipaynehsl
sipaynehsl Posts: 6
edited September 4 in LFD121 Class Forum

Hi again,

I am having more trouble with the lab exercises. This time it's "handling-errors", a Javascript exercise. I quickly got green responses from the first two fields but for the third field, even when I typed exactly the same output as given in the "give up" answer, I could not get it to go green. Is this a fault with the test expectation or is there a subtle gotcha in there somehow?

I also noted that the web page advises "catch any error into a variable named error" whereas the "give up" answer says to name it err. Super-trivial but may be relevant? (Needless to say, I have tried naming the variable every which way, and it stays yellow.)

Best Answer

  • dwheeler
    dwheeler Posts: 5
    Answer ✓

    In case my guess is correct, I've added some hints related to that here:
    https://github.com/ossf/wg-best-practices-os-developers/pull/613

    However, I'd like to verify that this really is the problem. So please do post
    what your final section answer was in handling-errors. My current guess
    is that there's a subtle mistake, and so our hint system should detect and
    report on it. Of course, it's possible that what we're doing is wrong, so I'd like
    to make sure what we're doing is correct.

    Thanks for your patience!

Answers

  • It works for me. In fact, the lab would fail on load if the purported correct answer was incorrect.

    Can you share the non-matching text, so we can puzzle it out?

    I did notice one potential missing hint. Did you use this?:
    console.error("Error:", result.message);
    If so, it should be:
    console.error("Error:", err.message);

  • sipaynehsl
    sipaynehsl Posts: 6
    edited September 5

    It works now... all my answers are correct, it announced. Very strange. Thank you for checking it out. The final section answer is:

    try {
      const result = divide(10, 2);
      console.log("Result:", result);
    } catch(err) {
      console.error("Error:", err.message);
    } 
    

    Just to reiterate that tiny note on the instructions under header 4: it only works if the variable's name is err not error.

  • Great!

    I've modified the hints to report issues in more cases, e.g., where the given answer is "result.message" instead of "err.message".

    If you have suggestions on how to improve the labs (e.g., "in case X it should give hint Y"), let us know! The official location for issue proposals is here:
    https://github.com/ossf/wg-best-practices-os-developers/issues

Categories

Upcoming Training