How do you throw an error from within a custom code step?

You can do that by using:

throw new Error("your error description")

The results will look something like this: