-
Some katas ask for throw an error in some situations, but I've tried to use try...catch, and trow new Error() and it doesn' work. And I van not find any help in docs. So how can I raise errors in katas? (Javascript) |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 1 reply
-
Maybe try using `throw new Error('some error message')` without try / catch
blocks. You just have to throw the error from within the function; the
tests will catch it accordingly (as long as the thrown error is expected
from the tests).
…On Mon, 19 Jul 2021 at 20:05, jotakar ***@***.***> wrote:
Some katas ask for throw an error in some situations, but I've tried to
use try...catch, and trow new Error() and it doesn' work. And I van not
find any help in docs. So how can I raise errors in katas? (Javascript)
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
<#2433>, or
unsubscribe
<https://github.com/notifications/unsubscribe-auth/AB3K4XCP44S4XVFENYMVY6LTYQIKDANCNFSM5ATR6BWA>
.
|
Beta Was this translation helpful? Give feedback.
-
The way of signaling an error might depend on a kata, so it would be better to ask in discourse of a specific kata. What seems suspicious is that a kata asks you to raise an error, but for some reason you went with try/catch what is an exact opposite of the task ( |
Beta Was this translation helpful? Give feedback.
The way of signaling an error might depend on a kata, so it would be better to ask in discourse of a specific kata.
What seems suspicious is that a kata asks you to raise an error, but for some reason you went with try/catch what is an exact opposite of the task (
try
andcatch
are used to handle an error, and not to raise it).try
andcatch
should not be necessary in solution (but again, it depends on what exactly kata wants you to do).