Skip to content

fix: Relax OpenColorIO exception handling#5164

Open
lgritz wants to merge 1 commit intoAcademySoftwareFoundation:mainfrom
lgritz:lg-ociorelax
Open

fix: Relax OpenColorIO exception handling#5164
lgritz wants to merge 1 commit intoAcademySoftwareFoundation:mainfrom
lgritz:lg-ociorelax

Conversation

@lgritz
Copy link
Copy Markdown
Collaborator

@lgritz lgritz commented Apr 23, 2026

In PR #5114, just a few weeks ago, I was trying to catch every possible OCIO exception. That was a good idea, but I was over-eager and treated every OCIO exception as if something really bad happened. I should have recognized that OCIO enjoys throwing exceptions for things where I would have just used an empty return value to indicate a simple failure to do what was asked.

So this patch is revising the approach as follows:

  • Exceptions thrown because it couldn't read a config properly (it was missing or broken), or couldn't produce a ColorProcessor when asked -- those are real problems that we should treat as serious errors.

  • Exceptions thrown because it can't satisfy a simple request (like "what is the name of the color space for this role" in a case where the role you passed is not known by the config) -- we should catch those exceptions, but it's not an "error" for OIIO, we just return an empty string because there is no color space for that role.

Also beefed up some of the documentation of our ColorConfig class methods to describe what happens with certain kinds of failures.

In PR 5114, just a few weeks ago, I was trying to catch every possible
OCIO exception. That was a good idea, but I was over-eager and treated
every OCIO exception as if something really bad happened. I should
have recognized that OCIO enjoys throwing exceptions for things where
I would have just used an empty return value to indicate a failure to
do what was asked.

So this patch is heavily revising the approach as follows:

* Exceptions thrown because it couldn't read a config properly (it was
  missing or broken), or couldn't produce a ColorProcessor -- those
  are real problems that we should treat as serious errors.

* Exceptions thrown because it can't satisfy a simple request (like
  "what is the name of the color space for this role" in a case where
  the role you passed is not known by the config) -- we should catch
  those exceptions, but it's not an "error" for OIIO, we just return
  an empty string because there is no color space for that role.

Also beefed up some of the documentation of our ColorConfig class
methods to describe what happens with certain kinds of failures.

Signed-off-by: Larry Gritz <lg@larrygritz.com>
lgritz added a commit to lgritz/OpenImageIO that referenced this pull request Apr 23, 2026
…5164)

In PR AcademySoftwareFoundation#5114, just a few weeks ago, I was trying to catch every possible
OCIO exception. That was a good idea, but I was over-eager and treated
every OCIO exception as if something really bad happened. I should
have recognized that OCIO enjoys throwing exceptions for things where
I would have just used an empty return value to indicate a simple failure
to do what was asked.

So this patch is heavily revising the approach as follows:

* Exceptions thrown because it couldn't read a config properly (it was
  missing or broken), or couldn't produce a ColorProcessor -- those
  are real problems that we should treat as serious errors.

* Exceptions thrown because it can't satisfy a simple request (like
  "what is the name of the color space for this role" in a case where
  the role you passed is not known by the config) -- we should catch
  those exceptions, but it's not an "error" for OIIO, we just return
  an empty string because there is no color space for that role.

Also beefed up some of the documentation of our ColorConfig class
methods to describe what happens with certain kinds of failures.

Signed-off-by: Larry Gritz <lg@larrygritz.com>
@lgritz
Copy link
Copy Markdown
Collaborator Author

lgritz commented Apr 23, 2026

@meimchu seem ok?

lgritz added a commit to lgritz/OpenImageIO that referenced this pull request Apr 23, 2026
…5164)

In PR AcademySoftwareFoundation#5114, just a few weeks ago, I was trying to catch every possible
OCIO exception. That was a good idea, but I was over-eager and treated
every OCIO exception as if something really bad happened. I should
have recognized that OCIO enjoys throwing exceptions for things where
I would have just used an empty return value to indicate a simple failure
to do what was asked.

So this patch is heavily revising the approach as follows:

* Exceptions thrown because it couldn't read a config properly (it was
  missing or broken), or couldn't produce a ColorProcessor -- those
  are real problems that we should treat as serious errors.

* Exceptions thrown because it can't satisfy a simple request (like
  "what is the name of the color space for this role" in a case where
  the role you passed is not known by the config) -- we should catch
  those exceptions, but it's not an "error" for OIIO, we just return
  an empty string because there is no color space for that role.

Also beefed up some of the documentation of our ColorConfig class
methods to describe what happens with certain kinds of failures.

Signed-off-by: Larry Gritz <lg@larrygritz.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant