General X++ Development

What is the difference between `throw error()` and `checkFailed()`?

Asked by Sunny Vasty· Aug 13, 2026· 1 answers

What is the difference between throw error() and checkFailed()?

SSunny Vasty75 reputation · answered Aug 13, 2026

throw error() logs the message and throws an exception, so normal execution stops unless something catches it.

X++
throw error('Something is wrong.');

checkFailed() logs the validation message and returns false.

X++
return checkFailed('Something is wrong.');

For methods such as validateWrite() that already return a boolean, checkFailed() is usually the better fit.