الفرق بين المراجعتين ل"Ruby/IOError"

من موسوعة حسوب
اذهب إلى التنقل اذهب إلى البحث
(أنشأ الصفحة ب'<noinclude>{{DISPLAYTITLE: صفحة الصنف <code>IOError</code> في روبي}}</noinclude> تصنيف: Ruby تصنيف: Ruby IOError يُطلق الاستث...')
 
ط (مراجعة وتدقيق.)
 
(مراجعتان متوسطتان بواسطة مستخدم واحد آخر غير معروضتين)
سطر 1: سطر 1:
<noinclude>{{DISPLAYTITLE: صفحة الصنف <code>IOError</code> في روبي}}</noinclude>
+
<noinclude>{{DISPLAYTITLE:الصنف <code>IOError</code> في روبي}}</noinclude>
 
[[تصنيف: Ruby]]
 
[[تصنيف: Ruby]]
[[تصنيف: Ruby IOError]]
+
[[تصنيف: Ruby Class]]
يُطلق الاستثناء <code>IOError</code> في حال امتلاء المُكدس (stack overflow).<syntaxhighlight lang="ruby">
+
[[تصنيف: Ruby Error]]
def me_myself_and_i
+
[[تصنيف: Ruby IO]]
  me_myself_and_i
+
يُطلق الاستثناء <code>IOError</code> عند فشل عملية [[Ruby/IO|إدخال/إخراج]] (IO operation) في روبي.<syntaxhighlight lang="ruby">
end
+
File.open("/etc/hosts") {|f| f << "example"}
me_myself_and_i
+
  #=> IOError: not opened for writing
</syntaxhighlight>سيُطلق الاستثناء:<syntaxhighlight lang="ruby">
 
SystemStackError: stack level too deep
 
  
 +
File.open("/etc/hosts") {|f| f.close; f.read }
 +
  #=> IOError: closed stream
 +
</syntaxhighlight>تذكر أنَّ فشل بعض عمليات [[Ruby/IO|الإدخال/الإخراج]] قد يؤدي إلى إطلاق الاستثناء <code>[[Ruby/SystemCallError|SystemCallError]]</code>، وهذا الاستثناء ليس متفرع من الصنف <code>IOError</code>.<syntaxhighlight lang="ruby">
 +
File.open("does/not/exist")
 +
  #=> Errno::ENOENT: No such file or directory - does/not/exist
 
</syntaxhighlight>
 
</syntaxhighlight>
  
 
==مصادر==
 
==مصادر==
*[http://ruby-doc.org/core-2.5.1/SystemStackError.html قسم  الصنف IOError في توثيق روبي الرسمي.]
+
*[http://ruby-doc.org/core-2.5.1/IOError.html صفحة الصنف IOError في توثيق روبي الرسمي.]

المراجعة الحالية بتاريخ 08:10، 8 ديسمبر 2018

يُطلق الاستثناء IOError عند فشل عملية إدخال/إخراج (IO operation) في روبي.

File.open("/etc/hosts") {|f| f << "example"}
  #=> IOError: not opened for writing

File.open("/etc/hosts") {|f| f.close; f.read }
  #=> IOError: closed stream

تذكر أنَّ فشل بعض عمليات الإدخال/الإخراج قد يؤدي إلى إطلاق الاستثناء SystemCallError، وهذا الاستثناء ليس متفرع من الصنف IOError.

File.open("does/not/exist")
  #=> Errno::ENOENT: No such file or directory - does/not/exist

مصادر