Does Ruby rescue statement modifier work with require ?
rescue
require
irb(main):001:0> require 'a' rescue nil LoadError: no such file to load -- a from (irb):1:in `require' from (irb):1 from :0
You can save from LoadError you just need to use the begin/end style, and not use the built-in rescue :
LoadError
begin/end
This works the way you expect:
begin require 'a' rescue LoadError => ex puts "Load error: #{ex.message}" end
Source: https://habr.com/ru/post/1438048/More articles:Python using argparse with cmd - pythonConst, static, extern and their combinations in C and C ++ - c ++What is a good and easy tool for Scrum Project Management in game development? - project-managementCan I get the name of the method by providing the method itself? - reflectionDisable DataGridView except scrolling - c #Can I hide the Adobe floating panel when displaying PDF in a browser? - browserReboot android app after shutdown AsyncTask - androidImplement DBAppender for login to insert logs into CouchDB - javaChanging the structure address in C ++ using ++ and - operator - c ++How to list colors in WinRT? - c #All Articles