Preventing BASIC crash unprotecting Calc sheets

How can I prevent the Illegal Argument Exception crash when BASIC attempts to unprotect a sheet using no (null) password?
On error does nothing & the macro crashes.
I want to use this automate some functions in Calc & skip properly protected sheets.

Hallo

Here is an Example for python

from com.sun.star.lang import IllegalArgumentException

def sheet_unprotect_test():
    doc = XSCRIPTCONTEXT.getDocument()
    sheets = doc.Sheets
    for sheet in sheets:
        try:
            sheet.unprotect('')
        except IllegalArgumentException:
            continue
        # do other stuff
        sheet.protect('')