انتقل إلى المحتوى
أمين أبوزيد
درس مخطط لهJNR-015-L02

هرم استثناءات التطبيق

  • الدرس 2 من 6
  • Junior
في هذا الدرس 4 موضوعات

هذا الدرس مخطط له. يعرض المخطط أدناه الموضوعات التي سيغطيها، ولم يُنشر الدرس الكامل بعد.

نص الدروس والتمارين باللغة الإنجليزية، بينما تبقى واجهة الموقع وعناوين الدروس بالعربية.

في هذا الدرس

design a small set of exceptions.

الموضوعات المخطط لها

  • Define a base ShopException (unchecked) and a few subclasses: NotFoundException, ConflictException, BusinessRuleException.
  • Services throw them; they say what happened, not which HTTP status.
  • Carry useful data: the entity name and id.
  • Keep the tree small; do not create one class per message.
تفاصيل المخطط المبدئي

عرض عملي

java
public class NotFoundException extends ShopException {
    public NotFoundException(String entity, Object id) { super(entity + " " + id + " not found"); }
}

اختبر فهمك

Does the service choose the HTTP status?

أظهر الإجابة

No; the advice maps the exception to a status.

التطبيق

طبّق هذا الدرس بمختبر الوحدة وتمارينها واختبارها.

المختبر والتمارين الاختبار

تعليم الدرس كمكتمل اختياري ويمكنك التراجع عنه في أي وقت. يبقى تقدمك محفوظًا في هذا المتصفح.

اكتب للبحث في المستويات والمراحل والوحدات والدروس.