Skip to content
Computer Science · Grade 11

Active learning ideas

Error Handling and Exception Management

Active learning works for error handling because students need to experience how exceptions disrupt flow before they can design fixes. By handling real runtime issues in low-stakes settings, students build confidence in anticipating where errors occur and how to respond. This topic demands trial, failure, and correction, all of which active methods provide better than passive explanation alone.

Ontario Curriculum ExpectationsCS.HS.P.5
30–50 minPairs → Whole Class4 activities

Activity 01

Problem-Based Learning45 min · Pairs

Pair Programming: File Reader Safeguards

Pairs write a program to read user-specified files, wrapping file operations in try-catch blocks. They test with invalid paths and missing files, then log errors and prompt users for corrections. Extend by creating a custom FileNotAccessibleException.

Explain the importance of robust error handling in user-facing applications.

Facilitation TipDuring Pair Programming: File Reader Safeguards, circulate and ask pairs to explain why their chosen exception type matches the error scenario, not just that it works.

What to look forPresent students with a code snippet containing a potential runtime error (e.g., division by zero). Ask them to identify the error and write the correct try-catch block to handle it, explaining their choice of exception type.

AnalyzeEvaluateCreateDecision-MakingSelf-ManagementRelationship Skills
Generate Complete Lesson

Activity 02

Problem-Based Learning35 min · Small Groups

Small Groups: Exception Scenario Relay

Divide class into groups; each gets a scenario like network timeout or division by zero. Groups implement handling with try-catch and pass code to next group for testing. Discuss strategies after relay.

Differentiate between checked and unchecked exceptions and their appropriate use.

Facilitation TipFor Exception Scenario Relay, require each group to present their scenario and handling strategy to the class before moving on, ensuring accountability.

What to look forPose the question: 'Imagine you are building a social media app. What are three specific types of errors a user might encounter, and how would you design your error handling strategy to inform them clearly without crashing the app?'

AnalyzeEvaluateCreateDecision-MakingSelf-ManagementRelationship Skills
Generate Complete Lesson

Activity 03

Problem-Based Learning30 min · Whole Class

Whole Class: Error Hunt Challenge

Project buggy code on screen with hidden exceptions; class calls out issues and suggests fixes. Students code their versions individually, then vote on best strategies in a share-out.

Design an error handling strategy for a program that interacts with external resources.

Facilitation TipIn the Error Hunt Challenge, provide intentionally messy code with overlapping try-catch blocks so students practice reducing redundancy and improving clarity.

What to look forProvide students with a scenario: 'A program attempts to read user data from a file that might not exist.' Ask them to write one sentence explaining whether this is likely a checked or unchecked exception and why. Then, list one action the program should take if the file is not found.

AnalyzeEvaluateCreateDecision-MakingSelf-ManagementRelationship Skills
Generate Complete Lesson

Activity 04

Problem-Based Learning50 min · Individual

Individual: Custom Exception Portfolio

Students design three custom exceptions for a banking app simulation, including invalid amount and insufficient funds. Implement in a main program with try-catch hierarchies and test cases.

Explain the importance of robust error handling in user-facing applications.

What to look forPresent students with a code snippet containing a potential runtime error (e.g., division by zero). Ask them to identify the error and write the correct try-catch block to handle it, explaining their choice of exception type.

AnalyzeEvaluateCreateDecision-MakingSelf-ManagementRelationship Skills
Generate Complete Lesson

A few notes on teaching this unit

Teach error handling by starting with concrete, visual failures like division by zero or file access problems so students see the crash firsthand. Avoid overwhelming them with theory early on. Use real-world analogies, like error messages being signposts that guide users back to safe paths. Research shows students grasp exceptions better when they simulate debugging in teams before writing their own handlers.

Successful learning looks like students confidently using try-catch blocks to intercept specific exceptions rather than wrapping all code in generic blocks. They should explain why a checked exception like FileNotFoundException needs compile-time handling, while NullPointerException does not. Clear, user-friendly responses to errors become second nature in their designs.


Watch Out for These Misconceptions

  • During Pair Programming: File Reader Safeguards, watch for students who wrap entire file-reading methods in a single try-catch with a generic Exception type.

    Use this activity to redirect them by asking: 'What specific errors could occur here? How would you handle each differently?' Have them rewrite the block to match exceptions like FileNotFoundException and IOException separately.

  • During Exception Scenario Relay, listen for groups that treat all exceptions the same way, using only unchecked exceptions regardless of the scenario.

    Challenge their approach by asking: 'Would a user appreciate a crash if a required file is missing, or would they prefer a clear message?' Have them adjust their handling to include checked exceptions where appropriate.

  • During Error Hunt Challenge, observe students who assume checked exceptions can be ignored because the code compiles anyway.

    Ask them to test their code after commenting out the try-catch block for a checked exception like ClassNotFoundException. When the program crashes, revisit why compile-time warnings exist in the first place.


Methods used in this brief