Skip to content

Commit

Permalink
gdalmdimtranslate: add error message when output format cannot be gue…
Browse files Browse the repository at this point in the history
…ssed

Fixes #11847
  • Loading branch information
rouault committed Feb 19, 2025
1 parent fec933e commit 1b2ec24
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
3 changes: 3 additions & 0 deletions apps/gdalmdimtranslate_lib.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1800,6 +1800,9 @@ GDALMultiDimTranslate(const char *pszDest, GDALDatasetH hDstDS, int nSrcCount,
osFormat = GetOutputDriverForRaster(pszDest);
if (osFormat.empty())
{
CPLError(CE_Failure, CPLE_AppDefined,
"Cannot determine output driver for dataset name '%s'",
pszDest);
return nullptr;
}
}
Expand Down
16 changes: 16 additions & 0 deletions autotest/utilities/test_gdalmdimtranslate_lib.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,22 @@ def test_gdalmdimtranslate_multidim_to_mem():
###############################################################################


@pytest.mark.skipif(
not gdaltest.vrt_has_open_support(),
reason="VRT driver open missing",
)
def test_gdalmdimtranslate_multidim_to_unknown_format():

with pytest.raises(
Exception,
match="Cannot determine output driver for dataset name 'unknown.unknown'",
):
gdal.MultiDimTranslate("unknown.unknown", "data/mdim.vrt")


###############################################################################


@pytest.mark.skipif(
not gdaltest.vrt_has_open_support(),
reason="VRT driver open missing",
Expand Down

0 comments on commit 1b2ec24

Please sign in to comment.