A Rubyist's Walk Along the C-side (Part 8): Exceptions

31-Mar-2022 1577
In the previous article, you saw TypedData objects, a type unique to the Ruby C API. In this article, we’ll look at how to raise errors and rescue from errors.Raising errors You’ve already seen one way to raise errors in part 4. The Check_Type function guards that a variable is of a particular Ruby type and will raise a TypeError otherwise.The Ruby C API provides builtin errors as global variables. The builtin errors are prefixed with rb_e (e.g. rb_eRuntimeError for the RuntimeError exception). This was covered in more detail in part 4.
Use coupon code:

RUBYONRAILS

to get 30% discount on our bundle!
Prepare for your next tech interview with our comprehensive collection of programming interview guides. Covering JavaScript, Ruby on Rails, React, and Python, these highly-rated books offer thousands of essential questions and answers to boost your interview success. Buy our 'Ultimate Job Interview Preparation eBook Bundle' featuring 2200+ questions across multiple languages. Ultimate Job Interview Preparation eBook Bundle