an exception occurs when you meet the error condition (in your case: when the file is not processed with sufficient detail)
raise ValueError('File not parsed completely/correctly')
raise the appropriate type of error using the appropriate message
Priyank Mehta
source share