ما لا يجب إخباره للعميل
في هذا الدرس 4 موضوعات
هذا الدرس مخطط له. يعرض المخطط أدناه الموضوعات التي سيغطيها، ولم يُنشر الدرس الكامل بعد.
نص الدروس والتمارين باللغة الإنجليزية، بينما تبقى واجهة الموقع وعناوين الدروس بالعربية.
في هذا الدرس
avoid leaking internals.
الموضوعات المخطط لها
- Never return stack traces, SQL, class names, or file paths.
- Database messages can reveal table names and values; map them to a safe message.
- Log the full exception server-side with a correlation id; give the client the id to quote.
- For unexpected errors return a generic 500 body.
تفاصيل المخطط المبدئي
عرض عملي
@ExceptionHandler(Exception.class)
ProblemDetail unexpected(Exception ex) {
log.error("Unhandled error", ex);
return ProblemDetail.forStatusAndDetail(HttpStatus.INTERNAL_SERVER_ERROR, "Unexpected error");
}اختبر فهمك
Where does the stack trace go?
أظهر الإجابة
Into the server log, not the response.
التطبيق
طبّق هذا الدرس بمختبر الوحدة وتمارينها واختبارها.
تعليم الدرس كمكتمل اختياري ويمكنك التراجع عنه في أي وقت. يبقى تقدمك محفوظًا في هذا المتصفح.