Improve link from API calls to errors

Open
#5,010 3 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
5/5
Estimated time
Over a week
Newbie friendliness
25/100
Issue type
Feature
Clarity
Needs clarification
Activity status
Active
Tech stack
c

Research direction

Start with the referring discussion at https://github.com/libvips/libvips/discussions/5009, then inspect VipsObject and the existing error-handling paths. The proposal is not settled; done would require an agreed design that reliably links errors across delayed calls, cached results, background workers, and thread handoffs.

Written by the indexing model from the issue text.

Description

enhancement

libvips API calls (eg. vips_image_new_from_file() or vips_add()) can fail and log error messages, but there is currently no reliable way to link an error message to a specific call.

Referring discussion: https://github.com/libvips/libvips/discussions/5009

Complications

  1. Errors can occur after the API call. For example _new_from_file() can fail when the first pixel is decoded, which may not happen until much later.
  2. Errors can occur before the API call. Results can come from the operation cache, and they might have errors from long before the API call that needs the result.
  3. Errors can be found in background workers, and they might be generating pixels for several top level functions.
  4. Errors in background threads can need to be passed to another thread for reporting.

Possible proposal?

  1. Have a parameter called context on VipsObject that holds an error buffer, and perhaps some other stuff.
  2. When an error occurs, log a message on the context of the nearest object (an operation, an image, a region, a source, etc.).
  3. Use vips_object_get_error(obj) to get an error message. This recursively walks the object and any associated objects (eg. down the image pipeline) and concatenates all the error buffers it finds.

(just a thought! maybe it wouldn't work)

Dominant language
C
Stars
11.7k
Forks
797
Avg merge
3d 6h
Merged PRs (30d)
15

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from libvips/libvips

All issues in libvips/libvips

Similar issues

More C issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.