Skip to content

Commit e658896

Browse files
committed
error message if MVT output folders cannot be created, or tiles cannot be written, to debug #12
1 parent 499933b commit e658896

File tree

1 file changed

+18
-2
lines changed

1 file changed

+18
-2
lines changed

src/transitmap/output/MvtRenderer.cpp

+18-2
Original file line numberDiff line numberDiff line change
@@ -665,16 +665,32 @@ void MvtRenderer::serializeTile(size_t x, size_t y, size_t z,
665665
ss << _cfg->mvtPath << "/";
666666

667667
ss << z;
668-
mkdir(ss.str().c_str(), S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH);
668+
int err = mkdir(ss.str().c_str(), S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH);
669+
670+
if (err == -1) {
671+
if (errno != EEXIST) {
672+
throw std::runtime_error("Could not create output directory " + ss.str());
673+
}
674+
}
669675

670676
ss << "/" << x;
671-
mkdir(ss.str().c_str(), S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH);
677+
err = mkdir(ss.str().c_str(), S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH);
678+
679+
if (err == -1) {
680+
if (errno != EEXIST) {
681+
throw std::runtime_error("Could not create output directory " + ss.str());
682+
}
683+
}
672684

673685
ss << "/" << ((1 << z) - 1 - y) << ".mvt";
674686

675687
std::fstream fo(ss.str().c_str(),
676688
std::ios::out | std::ios::trunc | std::ios::binary);
677689

690+
if (!fo.is_open()) {
691+
throw std::runtime_error("Could not open " + ss.str());
692+
}
693+
678694
std::string a;
679695

680696
tile->SerializeToString(&a);

0 commit comments

Comments
 (0)