Python Detect String Using Exception Handling In Spring