Just by looking at your code, I haven’t tested it - your custom exception (STOP) logic currently contains a return statement directly before the exception. Exception is never raised.
STOP
return
How to fix? Remove the aforementioned return statement