You can try replacing the @ERROR code with something like this to see what the error is.

Exit Val('&' + Right(DecToHex(@ERROR), 4))