@@ -1004,11 +1004,11 @@ static int outputOperations(
10041004 promoteTo3D, normalizeAxisOrder, outputOpt.quiet , strm);
10051005 if (!sourceObj.has_value ())
10061006 return 1 ;
1007- auto sourceCRS = nn_dynamic_pointer_cast<CRS>(* sourceObj);
1007+ auto sourceCRS = nn_dynamic_pointer_cast<CRS>(sourceObj. value () );
10081008 CoordinateMetadataPtr sourceCoordinateMetadata;
10091009 if (!sourceCRS) {
10101010 sourceCoordinateMetadata =
1011- nn_dynamic_pointer_cast<CoordinateMetadata>(* sourceObj);
1011+ nn_dynamic_pointer_cast<CoordinateMetadata>(sourceObj. value () );
10121012 if (!sourceCoordinateMetadata) {
10131013 strm.cerr
10141014 << " source CRS string is not a CRS or a CoordinateMetadata"
@@ -1027,11 +1027,11 @@ static int outputOperations(
10271027 promoteTo3D, normalizeAxisOrder, outputOpt.quiet , strm);
10281028 if (!targetObj.has_value ())
10291029 return 1 ;
1030- auto targetCRS = nn_dynamic_pointer_cast<CRS>(* targetObj);
1030+ auto targetCRS = nn_dynamic_pointer_cast<CRS>(targetObj. value () );
10311031 CoordinateMetadataPtr targetCoordinateMetadata;
10321032 if (!targetCRS) {
10331033 targetCoordinateMetadata =
1034- nn_dynamic_pointer_cast<CoordinateMetadata>(* targetObj);
1034+ nn_dynamic_pointer_cast<CoordinateMetadata>(targetObj. value () );
10351035 if (!targetCoordinateMetadata) {
10361036 strm.cerr
10371037 << " target CRS string is not a CRS or a CoordinateMetadata"
@@ -2112,9 +2112,9 @@ static int main_projinfo(PJ_CONTEXT *ctx, int argc, char **argv,
21122112 dbContext, user_string, std::string (), objectKind,
21132113 " input string" , buildBoundCRSToWGS84, allowUseIntermediateCRS,
21142114 promoteTo3D, normalizeAxisOrder, outputOpt.quiet , strm));
2115- if (!obj_opt)
2115+ if (!obj_opt. has_value () )
21162116 return 1 ;
2117- auto obj = * obj_opt;
2117+ auto obj = obj_opt. value () ;
21182118 if (guessDialect) {
21192119 auto dialect = WKTParser ().guessDialect (user_string);
21202120 strm.cout << " Guessed WKT dialect: " ;
@@ -2234,9 +2234,13 @@ static int main_projinfo(PJ_CONTEXT *ctx, int argc, char **argv,
22342234
22352235int projinfo (PJ_CONTEXT *ctx, int argc, char **argv, projinfo_cb_t callback,
22362236 void *user_data) {
2237-
2238- Streamer strm (callback, user_data);
2239- return main_projinfo (ctx, argc, argv, strm);
2237+ try {
2238+ Streamer strm (callback, user_data);
2239+ return main_projinfo (ctx, argc, argv, strm);
2240+ } catch (const std::exception &e) {
2241+ pj_log (ctx, PJ_LOG_ERROR, " Unexpected exception: %s" , e.what ());
2242+ }
2243+ return 1 ;
22402244}
22412245
22422246// ! @endcond
0 commit comments