Exception Handling • Exercise 4/4

Raise Custom Error

00:00
0
25 points

Instructions

Create a custom exception class ValidationError that inherits
from StandardError.

Then create a function validate_age that:
- Returns the age if between 0 and 150
- Raises ValidationError with a message otherwise

Define custom exceptions:
```ruby
class MyError < StandardError; end

raise MyError, "something went wrong"
```

Your Code

Results

Click "Run Tests" to see results