Skip to content

Commit 5ed1f06

Browse files
Slight simplification of error handling
1 parent 0f960e5 commit 5ed1f06

29 files changed

Lines changed: 115 additions & 318 deletions

src/interface/shared/exception.i

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -49,25 +49,18 @@ static void _set_python_exception() {
4949
}
5050
#if EXIV2_VERSION_HEX < 0x001c0000
5151
catch(Exiv2::AnyError const& e) {
52-
std::string msg = e.what();
53-
if (wcp_to_utf8(&msg))
54-
msg = e.what();
55-
PyObject* args = Py_BuildValue(
56-
"Ns", py_from_enum((Exiv2::ErrorCode)e.code()), msg.c_str());
57-
PyErr_SetObject(PyExc_Exiv2Error, args);
58-
Py_DECREF(args);
59-
}
6052
#else
6153
catch(Exiv2::Error const& e) {
54+
#endif
6255
std::string msg = e.what();
6356
if (wcp_to_utf8(&msg))
6457
msg = e.what();
6558
PyObject* args = Py_BuildValue(
66-
"Ns", py_from_enum((Exiv2::ErrorCode)e.code()), msg.c_str());
59+
"Ns", py_from_enum_%mangle(Exiv2::ErrorCode)
60+
(static_cast<long>(e.code())), msg.c_str());
6761
PyErr_SetObject(PyExc_Exiv2Error, args);
6862
Py_DECREF(args);
6963
}
70-
#endif
7164
SWIG_CATCH_STDEXCEPT
7265
fail:
7366
return;

src/swig-0_27_7/basicio_wrap.cxx

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -4299,25 +4299,18 @@ static void _set_python_exception() {
42994299
}
43004300

43014301
catch(Exiv2::AnyError const& e) {
4302+
4303+
4304+
43024305
std::string msg = e.what();
43034306
if (wcp_to_utf8(&msg))
43044307
msg = e.what();
43054308
PyObject* args = Py_BuildValue(
4306-
"Ns", py_from_enum((Exiv2::ErrorCode)e.code()), msg.c_str());
4309+
"Ns", py_from_enum_Exiv2_ErrorCode
4310+
(static_cast<long>(e.code())), msg.c_str());
43074311
PyErr_SetObject(PyExc_Exiv2Error, args);
43084312
Py_DECREF(args);
43094313
}
4310-
4311-
4312-
4313-
4314-
4315-
4316-
4317-
4318-
4319-
4320-
43214314
/*@SWIG:/usr/local/share/swig/4.3.1/typemaps/exception.swg,59,SWIG_CATCH_STDEXCEPT@*/ /* catching std::exception */
43224315
catch (std::invalid_argument& e) {
43234316
SWIG_exception_fail(SWIG_ValueError, e.what() );

src/swig-0_27_7/datasets_wrap.cxx

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -4321,25 +4321,18 @@ static void _set_python_exception() {
43214321
}
43224322

43234323
catch(Exiv2::AnyError const& e) {
4324+
4325+
4326+
43244327
std::string msg = e.what();
43254328
if (wcp_to_utf8(&msg))
43264329
msg = e.what();
43274330
PyObject* args = Py_BuildValue(
4328-
"Ns", py_from_enum((Exiv2::ErrorCode)e.code()), msg.c_str());
4331+
"Ns", py_from_enum_Exiv2_ErrorCode
4332+
(static_cast<long>(e.code())), msg.c_str());
43294333
PyErr_SetObject(PyExc_Exiv2Error, args);
43304334
Py_DECREF(args);
43314335
}
4332-
4333-
4334-
4335-
4336-
4337-
4338-
4339-
4340-
4341-
4342-
43434336
/*@SWIG:/usr/local/share/swig/4.3.1/typemaps/exception.swg,59,SWIG_CATCH_STDEXCEPT@*/ /* catching std::exception */
43444337
catch (std::invalid_argument& e) {
43454338
SWIG_exception_fail(SWIG_ValueError, e.what() );

src/swig-0_27_7/easyaccess_wrap.cxx

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -4277,25 +4277,18 @@ static void _set_python_exception() {
42774277
}
42784278

42794279
catch(Exiv2::AnyError const& e) {
4280+
4281+
4282+
42804283
std::string msg = e.what();
42814284
if (wcp_to_utf8(&msg))
42824285
msg = e.what();
42834286
PyObject* args = Py_BuildValue(
4284-
"Ns", py_from_enum((Exiv2::ErrorCode)e.code()), msg.c_str());
4287+
"Ns", py_from_enum_Exiv2_ErrorCode
4288+
(static_cast<long>(e.code())), msg.c_str());
42854289
PyErr_SetObject(PyExc_Exiv2Error, args);
42864290
Py_DECREF(args);
42874291
}
4288-
4289-
4290-
4291-
4292-
4293-
4294-
4295-
4296-
4297-
4298-
42994292
/*@SWIG:/usr/local/share/swig/4.3.1/typemaps/exception.swg,59,SWIG_CATCH_STDEXCEPT@*/ /* catching std::exception */
43004293
catch (std::invalid_argument& e) {
43014294
SWIG_exception_fail(SWIG_ValueError, e.what() );

src/swig-0_27_7/exif_wrap.cxx

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -4337,25 +4337,18 @@ static void _set_python_exception() {
43374337
}
43384338

43394339
catch(Exiv2::AnyError const& e) {
4340+
4341+
4342+
43404343
std::string msg = e.what();
43414344
if (wcp_to_utf8(&msg))
43424345
msg = e.what();
43434346
PyObject* args = Py_BuildValue(
4344-
"Ns", py_from_enum((Exiv2::ErrorCode)e.code()), msg.c_str());
4347+
"Ns", py_from_enum_Exiv2_ErrorCode
4348+
(static_cast<long>(e.code())), msg.c_str());
43454349
PyErr_SetObject(PyExc_Exiv2Error, args);
43464350
Py_DECREF(args);
43474351
}
4348-
4349-
4350-
4351-
4352-
4353-
4354-
4355-
4356-
4357-
4358-
43594352
/*@SWIG:/usr/local/share/swig/4.3.1/typemaps/exception.swg,59,SWIG_CATCH_STDEXCEPT@*/ /* catching std::exception */
43604353
catch (std::invalid_argument& e) {
43614354
SWIG_exception_fail(SWIG_ValueError, e.what() );

src/swig-0_27_7/image_wrap.cxx

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -4350,25 +4350,18 @@ static void _set_python_exception() {
43504350
}
43514351

43524352
catch(Exiv2::AnyError const& e) {
4353+
4354+
4355+
43534356
std::string msg = e.what();
43544357
if (wcp_to_utf8(&msg))
43554358
msg = e.what();
43564359
PyObject* args = Py_BuildValue(
4357-
"Ns", py_from_enum((Exiv2::ErrorCode)e.code()), msg.c_str());
4360+
"Ns", py_from_enum_Exiv2_ErrorCode
4361+
(static_cast<long>(e.code())), msg.c_str());
43584362
PyErr_SetObject(PyExc_Exiv2Error, args);
43594363
Py_DECREF(args);
43604364
}
4361-
4362-
4363-
4364-
4365-
4366-
4367-
4368-
4369-
4370-
4371-
43724365
/*@SWIG:/usr/local/share/swig/4.3.1/typemaps/exception.swg,59,SWIG_CATCH_STDEXCEPT@*/ /* catching std::exception */
43734366
catch (std::invalid_argument& e) {
43744367
SWIG_exception_fail(SWIG_ValueError, e.what() );

src/swig-0_27_7/iptc_wrap.cxx

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -4335,25 +4335,18 @@ static void _set_python_exception() {
43354335
}
43364336

43374337
catch(Exiv2::AnyError const& e) {
4338+
4339+
4340+
43384341
std::string msg = e.what();
43394342
if (wcp_to_utf8(&msg))
43404343
msg = e.what();
43414344
PyObject* args = Py_BuildValue(
4342-
"Ns", py_from_enum((Exiv2::ErrorCode)e.code()), msg.c_str());
4345+
"Ns", py_from_enum_Exiv2_ErrorCode
4346+
(static_cast<long>(e.code())), msg.c_str());
43434347
PyErr_SetObject(PyExc_Exiv2Error, args);
43444348
Py_DECREF(args);
43454349
}
4346-
4347-
4348-
4349-
4350-
4351-
4352-
4353-
4354-
4355-
4356-
43574350
/*@SWIG:/usr/local/share/swig/4.3.1/typemaps/exception.swg,59,SWIG_CATCH_STDEXCEPT@*/ /* catching std::exception */
43584351
catch (std::invalid_argument& e) {
43594352
SWIG_exception_fail(SWIG_ValueError, e.what() );

src/swig-0_27_7/metadatum_wrap.cxx

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -4321,25 +4321,18 @@ static void _set_python_exception() {
43214321
}
43224322

43234323
catch(Exiv2::AnyError const& e) {
4324+
4325+
4326+
43244327
std::string msg = e.what();
43254328
if (wcp_to_utf8(&msg))
43264329
msg = e.what();
43274330
PyObject* args = Py_BuildValue(
4328-
"Ns", py_from_enum((Exiv2::ErrorCode)e.code()), msg.c_str());
4331+
"Ns", py_from_enum_Exiv2_ErrorCode
4332+
(static_cast<long>(e.code())), msg.c_str());
43294333
PyErr_SetObject(PyExc_Exiv2Error, args);
43304334
Py_DECREF(args);
43314335
}
4332-
4333-
4334-
4335-
4336-
4337-
4338-
4339-
4340-
4341-
4342-
43434336
/*@SWIG:/usr/local/share/swig/4.3.1/typemaps/exception.swg,59,SWIG_CATCH_STDEXCEPT@*/ /* catching std::exception */
43444337
catch (std::invalid_argument& e) {
43454338
SWIG_exception_fail(SWIG_ValueError, e.what() );

src/swig-0_27_7/preview_wrap.cxx

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -4500,25 +4500,18 @@ static void _set_python_exception() {
45004500
}
45014501

45024502
catch(Exiv2::AnyError const& e) {
4503+
4504+
4505+
45034506
std::string msg = e.what();
45044507
if (wcp_to_utf8(&msg))
45054508
msg = e.what();
45064509
PyObject* args = Py_BuildValue(
4507-
"Ns", py_from_enum((Exiv2::ErrorCode)e.code()), msg.c_str());
4510+
"Ns", py_from_enum_Exiv2_ErrorCode
4511+
(static_cast<long>(e.code())), msg.c_str());
45084512
PyErr_SetObject(PyExc_Exiv2Error, args);
45094513
Py_DECREF(args);
45104514
}
4511-
4512-
4513-
4514-
4515-
4516-
4517-
4518-
4519-
4520-
4521-
45224515
/*@SWIG:/usr/local/share/swig/4.3.1/typemaps/exception.swg,59,SWIG_CATCH_STDEXCEPT@*/ /* catching std::exception */
45234516
catch (std::invalid_argument& e) {
45244517
SWIG_exception_fail(SWIG_ValueError, e.what() );

src/swig-0_27_7/properties_wrap.cxx

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -4323,25 +4323,18 @@ static void _set_python_exception() {
43234323
}
43244324

43254325
catch(Exiv2::AnyError const& e) {
4326+
4327+
4328+
43264329
std::string msg = e.what();
43274330
if (wcp_to_utf8(&msg))
43284331
msg = e.what();
43294332
PyObject* args = Py_BuildValue(
4330-
"Ns", py_from_enum((Exiv2::ErrorCode)e.code()), msg.c_str());
4333+
"Ns", py_from_enum_Exiv2_ErrorCode
4334+
(static_cast<long>(e.code())), msg.c_str());
43314335
PyErr_SetObject(PyExc_Exiv2Error, args);
43324336
Py_DECREF(args);
43334337
}
4334-
4335-
4336-
4337-
4338-
4339-
4340-
4341-
4342-
4343-
4344-
43454338
/*@SWIG:/usr/local/share/swig/4.3.1/typemaps/exception.swg,59,SWIG_CATCH_STDEXCEPT@*/ /* catching std::exception */
43464339
catch (std::invalid_argument& e) {
43474340
SWIG_exception_fail(SWIG_ValueError, e.what() );

0 commit comments

Comments
 (0)