Error databse streamlit

How can I give a correct error in the database? When I save the product, when the video file is not supported, it gives a correct error. Please look at the codes and tell me the problem.

for row in cur.execute(‘SELECT rowid, id, img, note FROM pics ORDER BY id’):
with st.form(f’ID-{row[0]}',clear_on_submit=True):
imgcol, notecol = st.columns([3, 2])
id=notecol.text_input(‘کد محصول’, row[1])
note=notecol.text_area(‘نام محصول’, row[3])
if row[2]:
img=row[2]
imgcol.image(row[2])
file=imgcol.file_uploader(‘تصاویر’, [‘png’, ‘jpg’, ‘gif’,‘jpeg’, ‘bmp’,‘mp4’])
if file:
img=file.read()
if notecol.form_submit_button(‘ذخیره محصول’):

            cur.execute(
                'UPDATE pics SET id=?, img=?, note=? WHERE id=?;', 
                (id, img, note, str(row[1]))
                )
            con.commit()
            st.experimental_rerun()
        if notecol.form_submit_button("حذف محصول"):
            cur.execute(f'''DELETE FROM pics WHERE rowid="{row[0]}";''')
            con.commit()
            st.experimental_rerun()

This error was given, I want to define an error instead of this error so that this error is not stored in the database, just correct an error

Missing Submit Button

This form has no submit button, which means that user interactions will never be sent to your Streamlit app.

To create a submit button, use the st.form_submit_button() function.

For more information, refer to the documentation for forms

UnidentifiedImageError: cannot identify image file <_io.BytesIO object at 0x7fc1db55e4d0>