Raise Exception rollback everything

Hi, i use ERPNext 14, i have one issue regarding raise Exception. Below is my code:

if error:
		# print('error_log name: ',error_log.name)
		raise Exception("There is error in Collection Report.")
		return False

Here i want ERPNext to popup a dialog in which it tells the user that there is an error and i want to store the error in a doctype (error_log). According to the above code, after the popup dialog, the record of error_log created and saved here is not exist.
If i uncomment the line for print the name of the error_log record, my terminal display it but the record is not there in the list.
And also, if i comment the line for the raise Exception, i can found the error_log in the list.

So what happens here? And how can i popup the dialog and at the same time store the error in my custom error_log doctype? Thank you