MDL-37654 core_course: ensure exceptions return static error codes for debugging purposes