fix: Relax OpenColorIO exception handling#5164
Open
lgritz wants to merge 1 commit intoAcademySoftwareFoundation:mainfrom
Open
fix: Relax OpenColorIO exception handling#5164lgritz wants to merge 1 commit intoAcademySoftwareFoundation:mainfrom
lgritz wants to merge 1 commit intoAcademySoftwareFoundation:mainfrom
Conversation
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>
Collaborator
Author
|
@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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.