Error/Exception Handling and Testing/Debugging Flashcards

1
Q

Define Logic

A

the order in which parts of code execute/run

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

Define Syntax Error/Parse Error

A

the scripting engine fails to recognise code

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

Define Run-Time Error

A

the scripting error encounters an error while the program is executing

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

Define Logic Error

A

scripting engine doesn’t behave as it should

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

What are the three categories of error types?

A

notice
warning
fatal

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

What is a Notice error type?

A

a harmless problem. Can be involved using explicit programming

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

What is a Warning error type?

A

something is clearly wrong and action should be taken

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

What is a Fatal error type?

A

something has gone terribly wrong and processing cannot continue

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

what does error_reporting do?

A

says which types of error messages PHP should generate

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

what does log_errors do?

A

PHP logs errors into a file. Is assigned the default value “off”

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

display_errors

A

prints errors to screen (stdout) and could be assigned to stderr

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

display_startup_errors

A

displays errors that occur when PHP first starts. Assigned to default value “off”

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

What is the structure of an error handler?

A

error_function_name(error_level, error_message, error_file, error_line, error_context)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

which two attributes are required in an error handler?

A

error_level and error_message

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

what does error_level do

A

specifies error report level for user_defined errors. Must be a value number

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

error_message

A

specifies the error message

17
Q

error_file

A

specifies which file the error occurred in

18
Q

error_line

A

specifies line number the error occurred in

19
Q

error_context

A

specifies an array containing every variable and their values that were in use when the error occurred

20
Q

What is an exception?

A

Something that is used to change the normal flow of the code execution if a specified (exceptional) error condition occurs

21
Q

What normally happens when an error is triggered?

A

current code state is changed, OR
code execution will switch to a predefined (custom) exception handler function, OR
depending on the situation, the handler may:
- resume execution from saved code state
- terminate the script execution
- continue script from a different location of the code

22
Q

What is a Try block

A

Contains the function using an exception
If the exception doesn’t trigger, code continues as normal
If it does, exception is thrown

23
Q

What is Throw

A

how you trigger the exception

each throw must have at least one catch

24
Q

What is Catch

A

retrieves an exception and creates an object containing exception information

25
Q

What are the four attributes of the exception class?

A

message : the exception message

code: the exception code
file: the filename where the exception was created
line: line where exception was create