Error handling for Item not found

I have written just simple script to print message item not found but i am getting this error message how to avoid this message and give custom message ?

Please use the frappe.db.get_value instead of the frappe.get_doc

Ok. What is function for quiting the execution for frappe if there further conditions but first condition failed then for stopping further process what can be used ? frappe.exit()?? or any other functions are there

Already provided the documentation so click on frappe.db.get_value and explore it.