redis: throw error if block request failed
authornetinetwalker <manuel.hilbing@googlemail.com>
Fri, 25 Sep 2015 22:26:52 +0000 (00:26 +0200)
committerest31 <MTest31@outlook.com>
Sat, 26 Sep 2015 15:36:59 +0000 (17:36 +0200)
Fixes #3196. Before, we didn't throw an error, and the engine thought the
block isn't occupied. But in fact it might be that redis is still loading,
and the block does exist in the database. The result was a cheesy map.

src/database-redis.cpp

index cc4e5badea7dd0a075b2cc270a748a6838400c9f..d7f5379772822529bbfb91dece3a9372eecf98b6 100644 (file)
@@ -118,12 +118,21 @@ std::string Database_Redis::loadBlock(const v3s16 &pos)
                freeReplyObject(reply);
                return str;
        }
-       case REDIS_REPLY_ERROR:
-               errorstream << "WARNING: loadBlock: loading block " << PP(pos)
-                       << " failed: " << reply->str << std::endl;
+       case REDIS_REPLY_ERROR: {
+               std::string errstr = reply->str;
+               freeReplyObject(reply);
+               errorstream << "loadBlock: loading block " << PP(pos)
+                       << " failed: " << errstr << std::endl;
+               throw FileNotGoodException(std::string(
+                       "Redis command 'HGET %s %s' errored: ") + errstr);
+       }
        }
+       errorstream << "loadBlock: loading block " << PP(pos)
+               << " returned invalid reply type " << reply->type
+               << ": " << reply->str << std::endl;
        freeReplyObject(reply);
-       return "";
+       throw FileNotGoodException(std::string(
+               "Redis command 'HGET %s %s' gave invalid reply."));
 }
 
 bool Database_Redis::deleteBlock(const v3s16 &pos)