0Pricing
Vibe Coding · درس

فهم رسائل الخطأ

اقرأ الأخطاء قبل لصقها في AI

فهم رسائل الخطأ درس مجاني في Vibe Coding على CoddyKit. هذا هو الدرس 1 من أصل 4. يمكنك قراءة الدرس كاملاً أدناه مجاناً — ثم تمرن عليه مباشرة في المتصفح باستخدام محرر أكواد مدمج ومدرس ذكاء اصطناعي متاح 24/7. هذا الدرس جزء من مسار التعلم في Vibe Coding، وتقدمك يتزامن عبر الويب وتطبيق CoddyKit. تتضمن دورة Vibe Coding 4 دروس في المجموع.

بعض أجزاء هذا الدرس لم تُترجم بعد وتظهر باللغة الإنجليزية.

Errors Are Clues, Not Walls

When you're building with AI and something breaks, your screen fills up with red text. It feels scary. But here's the truth: an error message is a clue, not a wall.

The computer is literally telling you what went wrong and where. Once you learn to read these clues, debugging becomes a conversation instead of a panic. And when you pair that skill with AI, you'll fix bugs faster than most experienced developers.

In this lesson, you'll learn to read errors before you paste them to tools like Cursor, Claude Code, or Copilot.

Anatomy of an Error

Most error messages have three parts you should hunt for:

  • The type — what kind of problem (e.g. TypeError, ReferenceError)
  • The message — a short human-ish description
  • The location — file name and line number

Here is a classic JavaScript error. Read it slowly, left to right.

TypeError: Cannot read properties of undefined (reading 'name')
    at showUser (app.js:14:22)
    at main (app.js:30:3)

Decode That Error

Let's decode the error from the last scene piece by piece:

  • TypeError → the kind of bug: we used a value the wrong way
  • Cannot read properties of undefined (reading 'name') → we tried to grab .name off something that doesn't exist
  • at showUser (app.js:14:22) → it happened in the showUser function, file app.js, line 14, column 22

That last part is gold. You now know exactly where to look: line 14.

The Stack Trace

The list of at ... lines is called the stack trace. Read it top to bottom: the top line is where the error actually exploded, and each line below shows what called it.

Beginners often paste the whole thing to AI and ignore it. But just glancing at the top line tells you which function to inspect first. The lines mentioning your own files matter most — lines deep in libraries are usually not your bug.

at showUser (app.js:14:22)   ← your code, START HERE
at main (app.js:30:3)        ← your code, who called it
at node_modules/.../run.js   ← library, usually ignore

See an Error Happen Live

Let's actually trigger one. Run this snippet. It tries to read .toUpperCase() on a value that is undefined, which throws the same family of error.

Read the message it prints — notice how it names the exact problem.

const user = { email: "ada@example.com" };
try {
  console.log(user.name.toUpperCase());
} catch (err) {
  console.log("Error type:", err.name);
  console.log("Message:", err.message);
}

Common Error Types

You'll meet the same handful of errors over and over. Knowing them on sight saves time:

  • SyntaxError — a typo the computer can't even read (missing bracket, comma)
  • ReferenceError — you used a name that doesn't exist (typo'd variable)
  • TypeError — a value exists but you used it the wrong way
  • RangeError — a number or length is out of bounds

When you can name the error type, you can tell AI what category of fix you need.

Read Before You Paste

Here's the habit that separates fast builders from frustrated ones: read the error for 10 seconds before reaching for AI.

Ask yourself three quick questions:

  • What's the error type?
  • What file and line does it point to?
  • What was I just doing when it broke?

Even if you still hand it to AI, answering these makes your prompt far sharper — and you'll often spot the fix yourself before AI even replies.

Errors Point at the Symptom, Not Always the Cause

One subtle trap: the line in the error is where things blew up, but the real cause might be earlier. In our example, line 14 reads user.name — but the actual bug might be that user was loaded wrong on line 8.

So treat the error location as your starting point, then trace backwards: where did this value come from? AI is great at this once you point it to the right region.

Browser vs Terminal Errors

You'll see errors in two main places:

  • Browser Console (press F12, click Console) — for front-end web code. Click the file:line link and it jumps you right to the code.
  • Terminal — for back-end / Node.js / build tools. Same anatomy, just no clickable link.

Tools like Replit, Bolt, and Cursor often surface these inline and even add a 'Fix with AI' button. But that button works best when you already understand the message.

A Quick Reading Drill

Read this error and try to answer in your head before scrolling: What type? What line? What's missing?

Answer: It's a ReferenceError — the variable totl doesn't exist (a typo for total) — on line 7. The fix is a one-character spelling correction. No AI needed, just careful reading.

ReferenceError: totl is not defined
    at calculateCart (cart.js:7:18)

Turn Reading Into a Reflex

Run this final example. It deliberately misspells a variable. Watch the console name the exact problem — then imagine how fast you'd fix it knowing how to read it.

The goal isn't to memorize every error. It's to build the reflex: stop, read the type, read the line, then act.

const total = 42;
try {
  console.log(totl); // typo on purpose
} catch (err) {
  console.log(err.name + ": " + err.message);
}

Quick Check

You see: TypeError: Cannot read properties of undefined (reading 'name') at showUser (app.js:14:22). Where should you look FIRST?

Recap: You Can Read Errors Now

You leveled up from 'red text = panic' to 'red text = clue'. You learned to:

  • Spot the error type, message, and location
  • Read a stack trace top-down and focus on your own files
  • Recognize common types: Syntax, Reference, Type, Range
  • Treat the error line as a starting point, then trace backwards

Next up: how to take this understanding and paste errors to AI effectively so it fixes the bug on the first try.

الأسئلة الشائعة

هل درس «فهم رسائل الخطأ» مجاني؟

نعم — نص درس «فهم رسائل الخطأ» كامل متاح مجاناً هنا على الويب. لتمرينه بشكل تفاعلي (محرر أكواد مدمج ومدرس ذكاء اصطناعي متاح 24/7) وفتح باقي دورة Vibe Coding، انتقل إلى CoddyKit PRO. تتضمن دورة Vibe Coding 4 دروس في المجموع.

ماذا ستتعلم في «فهم رسائل الخطأ»؟

اقرأ الأخطاء قبل لصقها في AI تتمرن على Vibe Coding مع أكواد عملية تشغلها مباشرة في المتصفح، ومدرس ذكاء اصطناعي متاح 24/7 يجيب على أسئلتك أثناء عملك.

هل أحتاج إلى خبرة سابقة لأبدأ Vibe Coding؟

لا تُشترط خبرة سابقة. Vibe Coding على CoddyKit منظم للمبتدئين حتى المتقدمين، لذا يمكنك البدء من هنا أو من البداية والتقدم بسرعتك الخاصة. هذا هو الدرس 1 من أصل 4.

كم من الوقت يستغرق درس «فهم رسائل الخطأ»؟

معظم دروس CoddyKit تستغرق حوالي 5–10 دقائق. كل منها موجز وتفاعلي، لذا تحرز تقدماً مستمراً وتستأنف من حيث توقفت عبر الويب والتطبيق.

هل يمكنني كتابة وتشغيل أكواد في درس Vibe Coding هذا؟

نعم. كل درس في Vibe Coding يتضمن محرر أكواد مدمج، لذا تكتب وتشغل أكواداً حقيقية مباشرة في متصفحك وتحصل على تعليقات فورية من الذكاء الاصطناعي — بدون إعداد محلي.

جميع الدروس في هذه الدورة

  1. فهم رسائل الخطأ
  2. لصق الأخطاء في AI بفعالية
  3. تضييق نطاق الخطأ
  4. عندما يتعثر AI
← العودة إلى Vibe Coding