Skip to content

Create clear exception handling of invalid inputs #4

Open

Description

@Col-E

For a sample: Col-E/Recaf#373

Essentially, if the input isn't parsable ensure the reason why is clearly described in a thrown exception. Allows the library user to handle invalid files easily without having to check for themselves.

Activity

  1. Col-E commented on May 29, 2024

    @Col-E
    OwnerAuthor

    Another recent case:

    java.lang.IllegalArgumentException: newLimit < 0: (-10 < 0)
            at java.base/java.nio.Buffer.createLimitException(Buffer.java:395)
            at java.base/java.nio.Buffer.limit(Buffer.java:369)
            at java.base/java.nio.ByteBuffer.limit(ByteBuffer.java:1529)
            at java.base/java.nio.ByteBuffer.limit(ByteBuffer.java:267)
            at software.coley.lljzip.util.ByteDataUtil.sliceExact(ByteDataUtil.java:302)
            at software.coley.lljzip.util.BufferData.slice(BufferData.java:83)
            at software.coley.lljzip.util.ByteData.sliceOf(ByteData.java:108)
            at software.coley.lljzip.util.ByteDataUtil.lambda$readLazyLongSlice$7(ByteDataUtil.java:508)
            at software.coley.lljzip.util.lazy.LazyByteData.get(LazyByteData.java:49)
    

    Error provided by user. It would be ideal to have each ByteData be assigned a label and to rethrow errors to contain that label so we can have some idea of where the issue comes from when we are not provided with a sample.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions