Exception chaining (cause)
Në shqip: Zinxhiri i gabimeve
ShpjegimiSQ
Kur kap një gabim dhe hedh një tjetër, ia jep të parin si „shkak“: throw new RuntimeException("S'u ruajt", e). Në stack trace sheh „Caused by:“ — dhe s'e humbet arsyen e vërtetë.
EnglishEN
When you catch an error and throw another, you pass the first as its “cause”: throw new RuntimeException("Couldn't save", e). The stack trace shows “Caused by:” — and you don't lose the real reason.
Si ta mendosh
Si raporti „vetura s'ndizet — sepse bateria është bosh“.
Lexoje në anglisht
Like the report “the car won't start — because the battery is flat”.
Shembull kodijava
try { db.ruaj(t); }
catch (SQLException e) { throw new RuntimeException("Termi s'u ruajt", e); }