Rescue error with custom exception

I would like to rescue some code with a custom exception class. Here
some code:

class CustomError < StandardError
end

begin
‘foo’.bar(:baz)
rescue CustomError

THIS IS FINE

end

However, my class is not able to rescue the NoMethodError exception.

Is there a way to rescue this exception with a custom class such as
CustomError?