In Python, you can use a try-except statement and raise an exception with a custom message.
For example:
try:
x = int(input())
except:
raise Exception("User input deemed invalid")
In JavaScript, you can try using a try-catch statement. You can use the 'throw' keyword to handle the error.