GoConqr has a new look! Let us know what you think.

Notes

Error Handling

Caitlin Bergan-Gander Computer Science GCSE English 1 page

Content of the notes (1)

Page 1

Error Handling

3 types of errors

·

Syntax

errors

·

Run-Time

errors

·

Logic

Errors

Syntax

Errors

·

These occur when there are mistakes with how

programming instructions are formatted.

Common examples are forgetting to use speech marks, or omitting brackets

·

Features like autocomplete can help programmers

avoid these errors as they can predict the command you are trying to use and

add it with correct formatting and spelling

·

Programming languages like scratch make use of

drag and drop style programming so whole commands can be dragged into the

program and used without having to worry about syntax

Sample

Syntax error in VB

Run-Time

Error

·

These are errors that cause the program to crash

while it is running

·

This commonly happens when formulas are wrong

and cause an impossible calculation to be achieved, such as by trying to divide

by 0

·

Another common example is when looping through

an array, but the loop goes higher than the number of elements in the array

·

Using the wrong data type can also lead to

run-time errors, such as if the user enters the word two, instead of the number

2 – this would result in trying to perform a calculation with a word instead of

a number, which is not possible

Sample

run-time error in VB

Logic

Errors

·

These are hardest to find as a logic error will

not stop the program from running

·

These occur when a valid, but incorrect command

is given

·

E.g. if you needed to turn left to get to the

bathroom, but you were given instructions to turn right, you would still be

able to travel, but would not perform the task you were trying to perform

Testing

for errors

·

We can use 3 techniques for finding errors while

our programs are running

·

Breakpoints

-

These can be added to the program to stop it at

certain places. This way, we can check

the status of any variables at a particular point in the program

·

Steps

-

We can step through code line by line, possible

going from the breakpoint. This lets us

see how the commands are working one at a time

·

Watches

-

We can use watches to check the values held in

any variables or arrays while the program is paused

Trace

Tables

·

These are used to help dry run an algorithm or

program

·

We use it to log the status of all variables as

a program runs. This is particularly

useful for working through looped sections of code (iterations)

·

We need to create a table with a column for each

variable

·

We work through the program, adding values to

the table on each iteration

Information

Description
GCSE Computer Science (Databases) Note on Error Handling, created by Caitlin Bergan-Gander on 22/02/2016.
Views
0
Rating

Feedback

What is it about?

What do you think of the new look?

How do you like it?