Commit 80f8e67c authored by Paal Kvamme's avatar Paal Kvamme
Browse files

Merge branch 'kvamme62/better-error-messages' into 'master'

Improved error messages

See merge request !85
parents a5b52d6d 0377dcea
Pipeline #54128 passed with stage
in 1 minute and 14 seconds
......@@ -705,8 +705,9 @@ public:
_accessor.reset();
}
if (_fd) {
_fd->xx_close();
auto victim = _fd;
_fd.reset();
victim->xx_close();
}
// Metadata remains accessible. Not sure whether this is a good idea.
}
......
This diff is collapsed.
......@@ -9,6 +9,11 @@
set -e
# Workaround for SDAPI bug that causes 5 minutes of retries on something
# that definitely shouldn't. This may case negative tests to run way
# too long.
export OPENZGY_SD_BACKOFF=4
cd $(dirname $0)/../..
# Local tricks in my environment to get a valid SAuth token.
......
......@@ -2373,6 +2373,71 @@ test_hammer()
for (int ii = 0; ii < threads; ++ii)
workers[ii].join();
}
/**
* Most errors thrown by SDAPI now get caught and re-thrown as OpenZGY
* exceptions. In some cases OpenZGY is able to provide a better error
* message than SDAPI.
*/
static void
test_sderrors()
{
typedef OpenZGY::IZgyWriter::size3i_t size3i_t;
const std::string filename = cloud_synt2_name();
SeismicStoreIOContext context(*Test_Utils::default_sd_context());
// Neither token not token callback were provided.
context.sdtoken("", "");
must_throw("Missing access token or callback in iocontext", [&](){
OpenZGY::IZgyReader::open(filename, &context);
});
// Token callback provided but it always returns empty.
std::string token;
std::function<std::string()> functor = [&token]() {return token;};
context.sdtokencb(functor, "");
must_throw("Missing access token, first callback returned empty", [&](){
OpenZGY::IZgyReader::open(filename, &context);
});
#if 1 // Might or might not throw... So not much point in testing?
// Token callback provided but after a while it returns empty.
token = InternalZGY::Environment::getStringEnv("OPENZGY_TOKEN");
{
auto r = OpenZGY::IZgyReader::open(filename, &context);
float data{0};
r->read(size3i_t{0,0,0}, size3i_t{1,1,1}, &data, 0);
token = "";
// This doesn't necessarily throw, as the GCS token might be cached.
//must_throw("Missing access token, callback returned empty", [&](){
try {
float data2{0};
r->read(size3i_t{64,64,64}, size3i_t{1,1,1}, &data2, 0);
if (verbose())
std::cerr << "Step 1: NO exception" << std::endl;
}
catch (const std::exception& ex) {
if (verbose())
std::cerr << "Step 1: exception " << ex.what() << std::endl;
}
//});
// Ditto, might not throw.
//must_throw("Missing access token, callback returned empty", [&](){
try {
r->close();
if (verbose())
std::cerr << "Step 2: NO exception" << std::endl;
}
catch (const std::exception& ex) {
if (verbose())
std::cerr << "Step 2: exception " << ex.what() << std::endl;
}
//});
}
#endif
}
#endif
namespace {
......@@ -2786,6 +2851,7 @@ public:
#ifdef HAVE_SD
register_test("api.readwrite_cloud", test_readwrite_cloud);
register_test("api.hammer", test_hammer);
register_test("api.sderrors", test_sderrors);
#endif
register_test("api.edgebricks", test_edgebricks);
register_test("api.bat_local_1", test_bat_local_1);
......
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