PyZombis aayush/issue#215@d6f045a
Social
Runestone in social media:
Follow @iRunestone
Our Facebook Page
Help support us:
Search
Table of Contents
Book Index
User
Assignments
Practice
Change Course
Instructor's Page
Progress Page
Edit Profile
Change Password
Register
Login
Dark Mode
Scratch Activecode
Help
FAQ
Instructors Guide
About Runestone
Report A Problem
2.
Raising an Exception
¶
2.1.
Catching the Exception
¶
2.2.
Handling Exceptions
¶
from browser import window, prompt, alert def save_data(): try: destination = prompt("Enter Destination") if not destination: raise ValueError("Destination cannot be empty") window.sessionStorage["Destination"] = destination description= prompt("Enter Description") if not description: raise ValueError("Description cannot be empty") window.sessionStorage["Description"] = description speech= prompt("Enter Speech") if not speech: raise ValueError("Speech cannot be empty") window.sessionStorage["Speech"] = speech except Exception as exception: alert(f'Error: {exception}') save_data()
Note: to test the exception you will need to change the properties of the file
You have attempted
of
activities on this page