borisbrodski / sevenzipjbinding

7-Zip-JBinding
http://sevenzipjbind.sourceforge.net/
Other
176 stars 50 forks source link

How to differentiate among various 7zip error cases #54

Open asthagarg2428 opened 2 years ago

asthagarg2428 commented 2 years ago

I'm using this in android project and I want to differentiate among the following cases, based on which I want the UI layer to make corresponding action.

  1. For a password protected file, passed password is empty (Action: I want user to be prompted with a dialog to 'enter password')
  2. For a password protected 7zip file, the passed password is incorrect. (Action: I want to show error message to 'enter correct password')
  3. Suppose I pass .aac file which is not supported (I want to show error message)
  4. Currently what I'm observing is that in all the above cases I'm getting SevenZipException with message asFile can't be opened with any of the registered codecs. Also this behaviour is different than that of zip(for zip is clear and straight forward). I'm thinking to return 3 different error code enums but I'm unable to differentiate among above error cases.

I'm using below code:

inArchive = SevenZip.openInArchive(
                null, inStream, OpenInCallback(password, logger.get())
            )

Thanks in advance :)