exam questions

Exam 70-480 All Questions

View all questions & answers for the 70-480 exam

Exam 70-480 topic 1 question 24 discussion

Actual exam question from Microsoft's 70-480
Question #: 24
Topic #: 1
[All 70-480 Questions]

You are developing an application that uses a third-party JavaScript library named doWork().
The library occasionally throws an "object is null or undefined" error with an error code of
-2146823281.
The application must:
✑ Extract and handle the exceptions thrown by doWork()
✑ Continue normal program execution if other exceptions occur
You need to implement the requirements.
Which code segment should you use?

  • A. Option A
  • B. Option B
  • C. Option C
  • D. Option D
Show Suggested Answer Hide Answer
Suggested Answer: C 🗳️
* The try statement lets you test a block of code for errors.
The catch statement lets you handle the error.
The JavaScript statements try and catch come in pairs:
try {

Block of code to try -
}
catch(err) {

Block of code to handle errors -
}
* object.number [= errorNumber]
Returns or sets the numeric value associated with a specific error. The Error object's default property is number.
* Example:
The following example causes an exception to be thrown and displays the error code that is derived from the error number. try
{
// Cause an error.
var x = y;
}
catch(e)
{
document.write ("Error Code: ");
document.write (e.number & 0xFFFF)
document.write ("<br />");
document.write ("Facility Code: ")
document.write(e.number>>16 & 0x1FFF)
document.write ("<br />");
document.write ("Error Message: ")
document.write (e.message)
}
The output of this code is as follows.

Error Code: 5009 -

Facility Code: 10 -

Error Message: 'y' is undefined -
Reference: JavaScript Errors - Throw and Try to Catch; number Property (Error) (JavaScript)

Comments

Chosen Answer:
This is a voting comment (?). It is better to Upvote an existing comment if you don't have anything to add.
Switch to a voting comment New
Currently there are no comments in this discussion, be the first to comment!
Community vote distribution
A (35%)
C (25%)
B (20%)
Other
Most Voted
A voting comment increases the vote count for the chosen answer by one.

Upvoting a comment with a selected answer will also increase the vote count towards that answer by one. So if you see a comment that you already agree with, you can upvote it instead of posting a new comment.

SaveCancel
Loading ...