الأخطاء في الشيفرة غير المتزامنة
في هذا الدرس 4 موضوعات
هذا الدرس مخطط له. يعرض المخطط أدناه الموضوعات التي سيغطيها، ولم يُنشر الدرس الكامل بعد.
نص الدروس والتمارين باللغة الإنجليزية، بينما تبقى واجهة الموقع وعناوين الدروس بالعربية.
في هذا الدرس
propagate and handle failures.
الموضوعات المخطط لها
- An exception completes the stage exceptionally; dependent stages are skipped and carry it forward.
exceptionally(fn): recover with a fallback value.handle((v, ex) -> ...): see both result and error;whenCompleteobserves without changing.join()throwsCompletionException;get()throwsExecutionException; the cause is wrapped.- An unobserved failed future loses the error silently; always attach handling or read it.
تفاصيل المخطط المبدئي
عرض عملي
CompletableFuture<List<Review>> r = reviewsF.exceptionally(ex -> List.of()); // degrade gracefullyاختبر فهمك
What does a downstream thenApply do when its source failed?
أظهر الإجابة
It is skipped and the failure propagates.
التطبيق
طبّق هذا الدرس بمختبر الوحدة وتمارينها واختبارها.
تعليم الدرس كمكتمل اختياري ويمكنك التراجع عنه في أي وقت. يبقى تقدمك محفوظًا في هذا المتصفح.