Error groups #292

Closed
opened 2026-01-29 20:41:29 +00:00 by claunia · 1 comment
Owner

Originally created by @andrew-aladev on GitHub (Sep 12, 2019).

Hello. I see brotli provides a wide list of errors:

#define BROTLI_DECODER_ERROR_CODES_LIST...
/* Errors caused by invalid input */
...
/* Memory allocation problems */
...

Today all these error codes have only one group: BROTLI_DECODER_RESULT_ERROR.

static BROTLI_NOINLINE BrotliDecoderResult SaveErrorCode(
  BrotliDecoderState* s, BrotliDecoderErrorCode e) {
  ...
  switch (e) {
    ...
    default:
      return BROTLI_DECODER_RESULT_ERROR;
  } 
}

So if user want to know when decoder received corrupted source he have to list all 16 codes. It makes too tight and unreliable connection between brotli implementation and application.

Can you please provide several error groups like: BROTLI_DECODER_RESULT_CORRUPTED_SOURCE, BROTLI_DECODER_RESULT_ALLOCATION_FAILED and etc? Thank you.

Originally created by @andrew-aladev on GitHub (Sep 12, 2019). Hello. I see brotli provides a wide list of errors: ``` #define BROTLI_DECODER_ERROR_CODES_LIST... /* Errors caused by invalid input */ ... /* Memory allocation problems */ ... ``` Today all these error codes have only one group: `BROTLI_DECODER_RESULT_ERROR`. ``` static BROTLI_NOINLINE BrotliDecoderResult SaveErrorCode( BrotliDecoderState* s, BrotliDecoderErrorCode e) { ... switch (e) { ... default: return BROTLI_DECODER_RESULT_ERROR; } } ``` So if user want to know when decoder received corrupted source he have to list all **16 codes**. It makes too tight and unreliable connection between brotli implementation and application. Can you please provide several error groups like: `BROTLI_DECODER_RESULT_CORRUPTED_SOURCE`, `BROTLI_DECODER_RESULT_ALLOCATION_FAILED` and etc? Thank you.
Author
Owner

@eustas commented on GitHub (Jan 28, 2020):

Actually, there are 2 groups of errors - "corrupted stream" and "fatal".
"fatal" means that:

  • either allocation failed (application is going to crash soon anyways);
  • or invocation code has problems (supplied invalid arguments, or hasn't set the static dictionary);
  • (or things have gone completely crazy, and "unreachable" point is reached)

The preferred way to deal with allocation problems is to use "custom memory manager" API. This way the embedder could decide what to do - wait until there is more memory accessible, or interrupt decoding. Even more - it helps to control the memory budget for a bunch of decoders...

@eustas commented on GitHub (Jan 28, 2020): Actually, there are 2 groups of errors - "corrupted stream" and "fatal". "fatal" means that: - either allocation failed (application is going to crash soon anyways); - or invocation code has problems (supplied invalid arguments, or hasn't set the static dictionary); - (or things have gone completely crazy, and "unreachable" point is reached) The preferred way to deal with allocation problems is to use "custom memory manager" API. This way the embedder could decide what to do - wait until there is more memory accessible, or interrupt decoding. Even more - it helps to control the memory budget for a bunch of decoders...
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/brotli#292