Exceptions let you handle errors gracefully and keep your app from crashing. You try risky code, and catch errors to respond properly.
try block contains code that might throw an exception.throw keyword raises an exception manually.catch block handles the exception and prevents crashes.Exception objects carry error messages you can access with getMessage().catch blocks for different exception types.