Talks
Speakers
Events
Topics
Sign in
Home
Talks
Speakers
Events
Topics
Leaderboard
Use
Analytics
Sign in
Suggest modification to this talk
Title
Description
You know how to raise and rescue exceptions. But do you know how they work, and how how to structure a robust error handling strategy for your app? Starting out with an in-depth walk-through of Ruby's Ruby's rich failure handling mechanisms -- including some features you may not have known about -- we'll move on to present strategies for implementing a cohesive error-handling policy for your application, based on real-world experience. Help us caption & translate this video! http://amara.org/v/GZCh/
Date
Summarized using AI?
If this talk's summary was generated by AI, please check this box. A "Summarized using AI" badge will be displayed in the summary tab to indicate that the summary was generated using AI.
Show "Summarized using AI" badge on summary page
Summary
Markdown supported
In this presentation titled "Exceptional Ruby," Avdi Grimm discusses the intricacies of failure handling and exceptions in the Ruby programming language. He begins by exploring the concept of failure within the context of programming, referencing Bertrand Meyer’s design by contract approach, where each method has a contract to fulfill. The talk dives into Ruby’s rich exception handling mechanisms, detailing both foundational knowledge and advanced techniques. Key points discussed include: - **Understanding Failure**: Failure occurs when a method cannot fulfill its contract, whether due to incorrect usage, coding mistakes, or external issues. - **Raising Exceptions**: Every exception in Ruby starts with the `raise` or `fail` methods. Grimm highlights the nuances of these methods, including customizing backtraces and creating error consoles. - **Handling Exceptions**: Through the `rescue` mechanism, Ruby allows developers to manage exceptions. Notably, exceptions should be reserved for truly exceptional circumstances and not expected situations like invalid input. - **Advanced Techniques**: The presentation covers using `retry`, `ensure`, and custom exception nesting to manage errors effectively. He warns against losing the context of exceptions by raising new ones without preserving the original. - **Failure Reporting**: Effective strategies for error reporting are emphasized, cautioning against failure cascades, where one error can lead to many more. The circuit breaker pattern is introduced as a way to manage repetitive failures in a controlled manner. - **Philosophical Insights**: Grimm shares insights on structuring a robust error handling strategy, including five questions to consider before raising exceptions and the importance of maintaining clean code with a focus on exception safety. - **Best Practices**: Recommendations include avoiding overly broad rescue clauses, establishing a single base exception for libraries, and ensuring a clear separation between business logic and failure handling. The talk encapsulates extensive insights into structuring error handling in Ruby applications, concluding with practical advice and an invitation to explore further resources, including an ebook expansion of the presentation. Grimm emphasizes that while managing exceptions, clarity and maintainability are paramount.
Suggest modifications
Cancel