aimnova.
DashboardMy LearningPaper MasteryStudy Plan

Aimnova site navigation

Stay in the loop

Get the latest study resources and updates

New features, study tips and exam insights — straight to your inbox.

IB Diploma

  • IB Past Papers
  • IB Study Notes
  • IB Question Bank
  • IB Mock Exams
  • IB Revision

IB Subjects

  • IB Math AA
  • IB Math AI
  • IB Economics
  • IB Business Management
  • IB Physics
  • IB Biology
  • View all IB subjects→

IB Past Papers

  • IB Math AA HL Past Papers
  • IB Math AA SL Past Papers
  • IB Math AI HL Past Papers
  • IB Math AI SL Past Papers
  • IB Economics HL Past Papers
  • IB Economics SL Past Papers
  • IB ESS Past Papers
  • View all past papers→

Study Resources

  • Study Notes
  • Question Bank
  • Mock Exams
  • Flashcards
  • Revision Guide
  • Exam Skills
  • Command Terms
  • Grade Calculator
  • Exam Timetable 2026

Aimnova

  • Features
  • Pricing
  • For Schools
  • For Parents
  • About Us
  • Blog
  • Contact
aimnova.

AI-powered study platform for smarter revision, past-paper analysis and examiner-style feedback.

TermsPrivacyCookies·© 2026 Aimnova. All rights reserved.8afc4e3

Aimnova is not affiliated with or endorsed by the International Baccalaureate Organization (IB).

NotesComputer Science HLTopic 6.1Exception handling
Back to Computer Science HL Topics
6.1.35 min read

Exception handling (Computer Science HL)

IB Computer Science • Unit 6

Exam preparation

Practice the questions examiners actually ask

Our question bank mirrors real IB exam papers. Practice under timed conditions and track your progress across topics.

Start Practicing

Contents

  • When something goes wrong at run time
  • try, except and finally
  • Handling, or preventing
  • Exam-style question
The big idea: An exception is a problem that appears while the program is running — not a mistake in the code's grammar.

Without handling, the program simply stops. With handling, it can say what went wrong and carry on.

Unexpected input

  • Letters typed where a number was wanted
  • An empty answer, or a date that does not exist
  • The commonest source, because people are the source

Resource unavailable

  • A file that is missing, or locked by something else
  • A network or database that does not respond
  • Nothing is wrong with your code — the world changed

Logic errors

  • Dividing by a value that turned out to be zero
  • Reading past the end of a list
  • The code ran, but on values nobody planned for

Free preview

This is the free notes preview

You're reading the free notes. Aimnova Pro unlocks the full study experience — and you can try it with your first topic free to keep:

  • FlashcardsLock in vocabulary and key terms with spaced repetition.
  • Practice questionsAnswer exam-style questions and get instant AI marking.
  • Mock exams & past-paper vaultSit full mocks and see exactly how examiners award marks.
  • Personalised study planA daily plan built around your exam date and weak areas.
Start Studying Free Full access to Aimnova Pro · cancel anytime
1

try — the risky part

2

except — what to do about it

3

finally — always, either way

4

Java says catch

Never catch everything and say nothing: A bare except that silently ignores the problem is worse than no handling at all.

The program appears to work while producing wrong results, and the cause is now invisible.

Practice with real exam questions

Answer exam-style questions and get AI feedback that shows you exactly what examiners want to see in a full-marks response.

Try Practice FreeYour first topic is free to keep • No credit card required

Validate first

  • Check before acting — is the list empty? is the divisor zero?
  • Right when you can reasonably predict the problem
  • Reads clearly, and costs nothing when all is well
  • Cannot cover everything: a file can vanish between the check and the read

Handle the exception

  • Let it happen, and deal with it when it does
  • Right when the problem is outside your control
  • The only option for files, networks and databases
  • Needs a specific message, or it tells the user nothing
Real programs do both: Validate the things you can predict — an empty field, a number out of range.

Handle the things you cannot — a missing file, a network that stops answering. Neither one alone is enough.
Why it matters beyond tidiness: A crash loses whatever the user was doing, and an unhandled error message can reveal file paths and internal details that help an attacker.

Handling exceptions is partly a security measure.

How this is tested — you must name the failure, the construct that catches it, and what the user is told. It comes up two ways:

Paper 2 — working with code

  • Describe exception handling, 3-5 marks
  • Add handling to a given fragment
  • Name the points of failure in a program

Paper 2 — the algorithmic-thinking question

  • Identify what could fail, with no code shown
  • Say what the program should do about it
The classic trap: Wrapping everything in one try and printing "an error occurred". Marks come from specific handling: which failure, which except, and a message the user can act on.
IB-style questionDescribe[5 marks]

A program reads a class list from a file and calculates the average mark. Describe the points of failure and how each should be handled.

Model answer plan

See the mark-by-mark plan — for / against / judgement, with marking guidance — in study mode.

Claim your free topic

Try an IB Exam Question — Free AI Feedback

Test yourself on Exception handling. Write your answer and get instant AI feedback — just like a real IB examiner.

the term exception. [1 mark]

Related Computer Science HL Topics

Continue learning with these related topics from the same unit:

6.1.1Variables and data types
6.1.2Substrings
6.1.4Debugging
6.2.1Static vs dynamic structures
View all Computer Science HL topics

Improve your exam technique

Command terms, paper structure, and mark-scheme tips for Computer Science HL

Previous
6.1.2Substrings
Next
Debugging6.1.4

21 questions to test your understanding

Reading is just the start. Students who tested themselves scored 82% on average — try IB-style questions with AI feedback.

Start FreeView All Computer Science HL Topics