lib/zold/verbose_thread.rb in zold-0.20.1 vs lib/zold/verbose_thread.rb in zold-0.20.2
- old
+ new
@@ -19,11 +19,13 @@
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.
require 'backtrace'
+require 'get_process_mem'
require_relative 'log'
+require_relative 'size'
# Verbose thread.
# Author:: Yegor Bugayenko (yegor256@gmail.com)
# Copyright:: Copyright (c) 2018 Yegor Bugayenko
# License:: MIT
@@ -35,9 +37,14 @@
end
def run(safe = false)
Thread.current.report_on_exception = false
yield
+ rescue Errno::ENOMEM => e
+ @log.error(Backtrace.new(e).to_s)
+ @log.error("We are too big in memory (#{Size.new(GetProcessMem.new.bytes.to_i)}), quitting; \
+this is not a normal behavior, you may want to report a bug to our GitHub repository")
+ abort
rescue StandardError => e
@log.error(Backtrace.new(e).to_s)
raise e unless safe
end
end