Skip to content

Commit de03bb3

Browse files
Refactor error handling to separate library and CLI error messages (#237)
Signed-off-by: aabhinavvvvvvv <[email protected]>
1 parent 859d0d4 commit de03bb3

22 files changed

+957
-198
lines changed

.github/workflows/build-steps.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ jobs:
8585
if: inputs.vfxyear < 2024
8686
shell: bash
8787
run: |
88-
build_scripts/${{ inputs.install_deps }}.bash
88+
bash build_scripts/${{ inputs.install_deps }}.bash
8989
9090
- name: Dependencies (aswf/ci-rawtoaces)
9191
if: inputs.vfxyear > 2023

.github/workflows/coverage.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ jobs:
1818
- name: Install OS dependencies
1919
shell: bash
2020
run: |
21-
build_scripts/install_deps_mac.bash
21+
bash build_scripts/install_deps_mac.bash
2222
2323
- name: Install coverage dependencies
2424
run: |

build_scripts/install_aces_container.bash

100755100644
File mode changed.

build_scripts/install_deps_linux.bash

100755100644
File mode changed.

build_scripts/install_deps_mac.bash

100755100644
File mode changed.

build_scripts/install_deps_windows.bash

100755100644
File mode changed.

build_scripts/install_deps_yum.bash

100755100644
File mode changed.

cmake/modules/FindCeres.cmake

100755100644
File mode changed.

include/rawtoaces/image_converter.h

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,39 @@ collect_image_files( const std::vector<std::string> &paths );
2525
class ImageConverter
2626
{
2727
public:
28+
/// Status codes for operation results.
29+
enum class Status
30+
{
31+
/// Operation completed successfully.
32+
Success,
33+
/// Output file already exists and overwrite is not enabled.
34+
FileExists,
35+
/// Input file does not exist.
36+
InputFileNotFound,
37+
/// Empty input filename provided.
38+
EmptyInputFilename,
39+
/// Filesystem error occurred.
40+
FilesystemError,
41+
/// Output directory does not exist and cannot be created.
42+
OutputDirectoryError,
43+
/// Invalid path format.
44+
InvalidPath,
45+
/// Failed to configure the image reader.
46+
ConfigurationError,
47+
/// Failed to read the image file.
48+
ReadError,
49+
/// Failed to apply colour space conversion.
50+
MatrixApplicationError,
51+
/// Failed to apply scale.
52+
ScaleApplicationError,
53+
/// Failed to apply crop.
54+
CropApplicationError,
55+
/// Failed to save the output file.
56+
WriteError,
57+
/// Unknown error.
58+
UnknownError
59+
};
60+
2861
/// The structure containing all parameters needed to configure image conversion.
2962
struct Settings
3063
{
@@ -211,6 +244,12 @@ class ImageConverter
211244
/// The conversion settings.
212245
Settings settings;
213246

247+
/// This property holds the error code from the most recent method call that returns a bool.
248+
Status status = Status::Success;
249+
250+
/// Error message from the most recent method call that returned false.
251+
std::string last_error_message;
252+
214253
/// Initialise the parser object with all the command line parameters
215254
/// used by this tool. The method also sets the help and usage strings.
216255
/// The parser object can be amended by the calling code afterwards if

src/bindings/py_util.cpp

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,9 @@ void util_bindings( nanobind::module_ &m )
1818
image_converter.def( nanobind::init<>() );
1919

2020
image_converter.def_rw( "settings", &ImageConverter::settings );
21+
image_converter.def_ro( "status", &ImageConverter::status );
22+
image_converter.def_rw(
23+
"last_error_message", &ImageConverter::last_error_message );
2124
image_converter.def( "process_image", &ImageConverter::process_image );
2225
image_converter.def(
2326
"get_WB_multipliers", &ImageConverter::get_WB_multipliers );
@@ -224,4 +227,31 @@ void util_bindings( nanobind::module_ &m )
224227
.value( "Soft", ImageConverter::Settings::CropMode::Soft )
225228
.value( "Hard", ImageConverter::Settings::CropMode::Hard )
226229
.export_values();
230+
231+
nanobind::enum_<ImageConverter::Status>( image_converter, "Status" )
232+
.value( "Success", ImageConverter::Status::Success )
233+
.value( "FileExists", ImageConverter::Status::FileExists )
234+
.value( "InputFileNotFound", ImageConverter::Status::InputFileNotFound )
235+
.value(
236+
"EmptyInputFilename", ImageConverter::Status::EmptyInputFilename )
237+
.value( "FilesystemError", ImageConverter::Status::FilesystemError )
238+
.value(
239+
"OutputDirectoryError",
240+
ImageConverter::Status::OutputDirectoryError )
241+
.value( "InvalidPath", ImageConverter::Status::InvalidPath )
242+
.value(
243+
"ConfigurationError", ImageConverter::Status::ConfigurationError )
244+
.value( "ReadError", ImageConverter::Status::ReadError )
245+
.value(
246+
"MatrixApplicationError",
247+
ImageConverter::Status::MatrixApplicationError )
248+
.value(
249+
"ScaleApplicationError",
250+
ImageConverter::Status::ScaleApplicationError )
251+
.value(
252+
"CropApplicationError",
253+
ImageConverter::Status::CropApplicationError )
254+
.value( "WriteError", ImageConverter::Status::WriteError )
255+
.value( "UnknownError", ImageConverter::Status::UnknownError )
256+
.export_values();
227257
}

0 commit comments

Comments
 (0)