الفرق بين المراجعتين لصفحة: «Ruby/StandardError»
< Ruby
لا ملخص تعديل |
جميل-بيلوني (نقاش | مساهمات) ط مراجعة وتدقيق. |
||
| سطر 1: | سطر 1: | ||
معظم أخطاء الأنواع تنحدر من الصنف <code>StandardError</code> | معظم أخطاء الأنواع تنحدر من الصنف <code>StandardError</code>؛ ستُعالج الكتلة <code>rescue</code> التي لا تحدد الصنف <code>[[Ruby/Exception|Exception]]</code> بشكل صريح كل الأخطاء <code>StandardError</code> (دون غيرها).<syntaxhighlight lang="ruby"> | ||
def foo | def foo | ||
raise "Oups" | raise "Oups" | ||
end | end | ||
foo rescue "Hello" #=> "Hello" | foo rescue "Hello" #=> "Hello" | ||
</syntaxhighlight> | </syntaxhighlight>الشيفرة التالية:<syntaxhighlight lang="ruby"> | ||
require 'does/not/exist' rescue "Hi" | require 'does/not/exist' rescue "Hi" | ||
</syntaxhighlight>ستطلق | </syntaxhighlight>ستطلق استثناء بالشكل التالي:<syntaxhighlight lang="text"> | ||
LoadError: no such file to load -- does/not/exist | LoadError: no such file to load -- does/not/exist | ||
</syntaxhighlight>{{DISPLAYTITLE: | </syntaxhighlight>{{DISPLAYTITLE:الصنف <code>StandardError</code> في روبي}}</noinclude> | ||
[[تصنيف: Ruby]] | [[تصنيف: Ruby]] | ||
[[تصنيف: Ruby | [[تصنيف: Ruby Class]] | ||
[[تصنيف: Ruby Error]] | |||
== مصادر == | == مصادر == | ||
*[http://ruby-doc.org/core-2.5.1/StandardError.html | *[http://ruby-doc.org/core-2.5.1/StandardError.html صفحة الصنف StandardError في توثيق روبي الرسمي.] | ||
المراجعة الحالية بتاريخ 09:20، 4 ديسمبر 2018
معظم أخطاء الأنواع تنحدر من الصنف StandardError؛ ستُعالج الكتلة rescue التي لا تحدد الصنف Exception بشكل صريح كل الأخطاء StandardError (دون غيرها).
def foo
raise "Oups"
end
foo rescue "Hello" #=> "Hello"
الشيفرة التالية:
require 'does/not/exist' rescue "Hi"
ستطلق استثناء بالشكل التالي:
LoadError: no such file to load -- does/not/exist