Commit ddbee053 authored by Paal Kvamme's avatar Paal Kvamme
Browse files

User opt-in for the readonly kludge. Throw specific error message for "must be read-only".

parent 72ebc592
Pipeline #59696 passed with stages
in 14 minutes and 13 seconds
......@@ -33,6 +33,7 @@ ZgyEndOfFile::ZgyEndOfFile(const std::string& arg) : ZgyError(arg) {}
ZgySegmentIsClosed::ZgySegmentIsClosed(const std::string& arg) : ZgyError(arg) {}
ZgyAborted::ZgyAborted(const std::string& arg) : ZgyError(arg) {}
ZgyMissingFeature::ZgyMissingFeature(const std::string& arg) : ZgyError(arg) {}
ZgyNotReadOnlyError::ZgyNotReadOnlyError(const std::string& arg) : ZgyError(arg) {}
namespace {
static std::string get_error(const std::string& filename, int system_errno)
......
......@@ -249,6 +249,21 @@ public:
ZgyIoError(const std::string& filename, int system_errno);
};
/**
* \brief Data must be read-only.
*
* Some operations such as alturl require that the data is flagged
* read-only. This was not the case here.
*
* Thread safety: Exceptions defined in this module are safe.
*/
class OPENZGY_API ZgyNotReadOnlyError: public ZgyError
{
public:
/** \copybrief OpenZGY::Errors::ZgyNotReadOnlyError */
ZgyNotReadOnlyError(const std::string& filename);
};
/**
* @}
*/
......
......@@ -1928,6 +1928,9 @@ SeismicStoreFile::altUrl(const std::string& filename) const
<< "\n");
return url;
}
catch (const seismicdrive::SDExpectedReadOnlyDatasetException& ex) {
throw OpenZGY::Errors::ZgyNotReadOnlyError(ex.what());
}
catch (const std::exception& ex) {
_dataset->throwCloudException(ex, "altUrl");
throw; // not reached, but compiler might not realize that.
......
......@@ -2075,6 +2075,9 @@ test_all_exceptions()
must_throw("Bogus file name:", [&](){
throw ZgyIoError("Bogus file name", 2);
});
must_throw("Exception test", [&](){
throw ZgyNotReadOnlyError("Exception test");
});
}
static void
......@@ -2805,7 +2808,7 @@ ok_alturl(const std::string& filename)
return false;
}
}
catch (const std::exception& ex)
catch (const OpenZGY::Errors::ZgyNotReadOnlyError& ex)
{
showex(ex);
if (verbose())
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment