التابع report_on_exception= الخاص بالصنف Thread في روبي
يُعيد التابع report_on_exception= الحالة الجديدة. عند إعطائه القيمة true، سترث كل المهمة الفرعية التي تم إنشاؤها بعد ذلك الشرط (condition) وتبعث رسالة على المجرى $ stderr إذا أدى استثناء ما إلى إنهاء مهمة فرعية:
هذا سوف ينتج:
In new thread
#<Thread:...prog.rb:2> terminated with exception (report_on_exception is true):
Traceback (most recent call last):
prog.rb:4:in `block in <main>': Exception from thread (RuntimeError)
In the main thread
انظر أيضا صفحة ::report_on_exception.
يوجد أيضًا تابع نسخة (instance level method) لتعيين هذا الخيار لمهمة فرعية معينة، راجع report_on_exception=.
البنية العامة
report_on_exception= boolean→ true or false
القيمة المُعادة
أمثلة
مثال على استخدام التابع report_on_exception=:
Thread.report_on_exception = true
t1 = Thread.new do
puts "In new thread"
raise "Exception from thread"
end
sleep(1)
puts "In the main thread"
انظر أيضا
- التابع
report_on_exception: يعيد التابعreport_on_exceptionحالة "report on exception". - التابع
run: يوقظ التابعrunالمهمة الفرعيةthr، مما يجعلها متاحة للجدولة.