Question
Need this in JavaScript and PHP. ASAP(Please make sure there are no errors and code compiles) Assessment Requirements Print to the console the following messages:
Need this in JavaScript and PHP. ASAP(Please make sure there are no errors and code compiles)
Assessment Requirements
Print to the console the following messages:
Assessment 7 Logging Exceptionsto a File.
Testing Try/Catch for Divide by Zero, File Does Not Exist, Array Out of Bounds, and Array is Null scenarios.
All console error messages are printed from error log file.
Create a logfile. Redirect the stdErr stream to write to your logfile.
Create a function, DisplayLogfile(), that will read the logfile and display to the console.
Create a function named, DivideByZero(), which will attempt to divide a number by 0.
Create a function named, FileDoesNotExist(), which will attempt to open a non-existent file named, NoFileNamedThis.txt.
Create a function named, ArrayOutOfBounds(), which will create an array and then try to access a non-existent index in that an array. (Hint: If there are 5 items in the array then the code might try to access item 6 for instance.)
Create a function named ArrayIsNull(), which will create an array and then set it equal to null before trying to access an item in the array.
Create a try/catch block.
From the try portion, call the function, DivideByZero().
In the catch portion, write the error message contained in the exception object to the standard error stream.
Create a try/catch block.
From the try portion, call the function, FileDoesNotExist().
In the catch portion, write the error message contained in the exception object to the standard error stream.
Create a try/catch block.
From the try portion, call the function, ArrayOutOfBounds().
In the catch portion, write the error message contained in the exception object to the standard error stream.
Create a try/catch block.
From the try portion, call the function, ArrayIsNull().
In the catch portion, write the error message contained in the exception object to the standard error stream.
Call the DisplayLogFile() function to display the contents of the log file your program has created.
EXPECTED OUTPUT
Note: Error messages might differ from language to language and the file path as well.
Assessment 7 Logging Exceptions to a File.
Testing Try/Catch for Divide by Zero, File Does Not Exist, Array Out of Bounds, and Array is Null scenarios. All console error messages are printed from error log file.
Attempted to divide by zero.
Could not find file C:\NoFileNamedThis.txt
Index was outside the bounds of the array.
Object reference not set to an instance of an object.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started