المكتبة التقنية ←

رسائل أخطاء Oracle مفهومة لمستخدمي APEX

English version

ORA-01400 and ORA-00001 are meaningful to a developer, but they rarely tell an end user what to do next. An APEX error-handling function can translate known failures into useful messages while preserving diagnostic detail for the team.

Initialize the result properly

Use APEXERROR.INITERROR_RESULT with the incoming error record. Oracle recommends this initialization pattern for compatibility with changes to the result type.

Map known business constraints

For a uniqueness error, extract the constraint name and look it up in a controlled mapping. A message such as 'A request with this reference already exists' is more useful than exposing a schema and constraint name. Do not map every uniqueness error to the same field if different constraints represent different rules.

For required values, prefer an item validation that guides the user early. Database constraints should remain the final integrity boundary.

Keep diagnosis possible

Unexpected errors should receive a safe message and a reference that support staff can investigate. Keep stack traces and sensitive details out of the user-facing notification. Logging itself must not make the original failure harder to understand.

Test duplicate values, missing required fields, unexpected exceptions, and errors raised from different page processes. A friendly message should explain a real failure; it must not turn a failed operation into an apparent success.

References: INITERRORRESULT and APEX_ERROR utilities.

النسخة العربية

رسائل ORA-01400 وORA-00001 مفهومة للمطور، لكنها غالبًا لا توضح للمستخدم يعمل إيه. Error Handling Function في APEX تقدر تحول الأخطاء المعروفة لرسائل مفيدة، مع الاحتفاظ بتفاصيل التشخيص للفريق.

جهّز النتيجة بالطريقة الصحيحة

استخدم APEXERROR.INITERROR_RESULT مع سجل الخطأ الداخل. Oracle توصي بالطريقة دي للتوافق مع التغييرات المستقبلية في نوع النتيجة.

اربط القيود برسائل العمل

في خطأ التكرار، استخرج اسم الـConstraint واربطه برسالة محددة من قائمة موثوقة. مثلًا: «يوجد طلب بنفس المرجع» أوضح من عرض اسم Schema وConstraint. ما تربطش كل أخطاء التكرار بنفس الحقل لو القيود بتمثل قواعد مختلفة.

للقيم المطلوبة، استخدم Validation مبكر يوجه المستخدم، مع الإبقاء على قيد قاعدة البيانات كحماية نهائية لسلامة البيانات.

حافظ على إمكانية التشخيص

الخطأ غير المتوقع يحتاج رسالة آمنة ومرجعًا يقدر الدعم يبحث به. تفاصيل Stack Trace والبيانات الحساسة مكانها مش إشعار المستخدم. وآلية التسجيل نفسها ما تخفيش الخطأ الأصلي.

اختبر التكرار والحقول الناقصة والاستثناءات غير المتوقعة والأخطاء في Processes مختلفة. الرسالة اللطيفة لازم تشرح الفشل، مش تعرضه للمستخدم كأن العملية نجحت.

المراجع: INITERRORRESULT وAPEX_ERROR.