mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-01-28 16:27:01 -05:00
Merge pull request #17 from RetroShare/master
Improve error reporting in createChannelV2
This commit is contained in:
commit
dd96419ffb
@ -1063,49 +1063,44 @@ bool p3GxsChannels::createChannelV2(
|
|||||||
RsGxsCircleType circleType, const RsGxsCircleId& circleId,
|
RsGxsCircleType circleType, const RsGxsCircleId& circleId,
|
||||||
RsGxsGroupId& channelId, std::string& errorMessage )
|
RsGxsGroupId& channelId, std::string& errorMessage )
|
||||||
{
|
{
|
||||||
// do some checks
|
const auto fname = __PRETTY_FUNCTION__;
|
||||||
|
const auto failure = [&](const std::string& err)
|
||||||
|
{
|
||||||
|
errorMessage = err;
|
||||||
|
RsErr() << fname << " " << err << std::endl;
|
||||||
|
return false;
|
||||||
|
};
|
||||||
|
|
||||||
|
if(!authorId.isNull() && !rsIdentity->isOwnId(authorId))
|
||||||
|
return failure("authorId must be either null, or of an owned identity");
|
||||||
|
|
||||||
if( circleType != RsGxsCircleType::PUBLIC
|
if( circleType != RsGxsCircleType::PUBLIC
|
||||||
&& circleType != RsGxsCircleType::EXTERNAL
|
&& circleType != RsGxsCircleType::EXTERNAL
|
||||||
&& circleType != RsGxsCircleType::NODES_GROUP
|
&& circleType != RsGxsCircleType::NODES_GROUP
|
||||||
&& circleType != RsGxsCircleType::LOCAL
|
&& circleType != RsGxsCircleType::LOCAL
|
||||||
&& circleType != RsGxsCircleType::YOUR_EYES_ONLY)
|
&& circleType != RsGxsCircleType::YOUR_EYES_ONLY)
|
||||||
{
|
return failure("circleType has invalid value");
|
||||||
errorMessage = "circleType has invalid value";
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
switch(circleType)
|
switch(circleType)
|
||||||
{
|
{
|
||||||
case RsGxsCircleType::EXTERNAL:
|
case RsGxsCircleType::EXTERNAL:
|
||||||
if(circleId.isNull())
|
if(circleId.isNull())
|
||||||
{
|
return failure("circleType is EXTERNAL but circleId is null");
|
||||||
errorMessage = "circleType is EXTERNAL but circleId is null";
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case RsGxsCircleType::NODES_GROUP:
|
case RsGxsCircleType::NODES_GROUP:
|
||||||
{
|
{
|
||||||
RsGroupInfo ginfo;
|
RsGroupInfo ginfo;
|
||||||
|
|
||||||
if(!rsPeers->getGroupInfo(RsNodeGroupId(circleId), ginfo))
|
if(!rsPeers->getGroupInfo(RsNodeGroupId(circleId), ginfo))
|
||||||
{
|
return failure( "circleType is NODES_GROUP but circleId does not "
|
||||||
errorMessage = "circleType is NODES_GROUP but circleId does not "
|
"correspond to an actual group of friends" );
|
||||||
"correspond to an actual group of friends";
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
if(!circleId.isNull())
|
if(!circleId.isNull())
|
||||||
{
|
return failure( "circleType requires a null circleId, but a non "
|
||||||
errorMessage = "circleType requires a null circleId, but a non "
|
"null circleId (" + circleId.toStdString() +
|
||||||
"null circleId (";
|
") was supplied" );
|
||||||
errorMessage += circleId.toStdString();
|
|
||||||
errorMessage += ") was supplied";
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1139,33 +1134,18 @@ bool p3GxsChannels::createChannelV2(
|
|||||||
|
|
||||||
uint32_t token;
|
uint32_t token;
|
||||||
if(!createGroup(token, channel))
|
if(!createGroup(token, channel))
|
||||||
{
|
return failure("Failure creating GXS group");
|
||||||
errorMessage = "Failed creating GXS group.";
|
|
||||||
std::cerr << __PRETTY_FUNCTION__ << " Error! " << errorMessage
|
|
||||||
<< std::endl;
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
// wait for the group creation to complete.
|
// wait for the group creation to complete.
|
||||||
RsTokenService::GxsRequestStatus wSt =
|
RsTokenService::GxsRequestStatus wSt =
|
||||||
waitToken( token, std::chrono::milliseconds(5000),
|
waitToken( token, std::chrono::seconds(5),
|
||||||
std::chrono::milliseconds(20) );
|
std::chrono::milliseconds(50) );
|
||||||
if(wSt != RsTokenService::COMPLETE)
|
if(wSt != RsTokenService::COMPLETE)
|
||||||
{
|
return failure( "GXS operation waitToken failed with: " +
|
||||||
errorMessage = "GXS operation waitToken failed with: "
|
std::to_string(wSt) );
|
||||||
+ std::to_string(wSt);
|
|
||||||
std::cerr << __PRETTY_FUNCTION__ << " Error! " << errorMessage
|
|
||||||
<< std::endl;
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(!RsGenExchange::getPublishedGroupMeta(token, channel.mMeta))
|
if(!RsGenExchange::getPublishedGroupMeta(token, channel.mMeta))
|
||||||
{
|
return failure("Failure getting updated group data.");
|
||||||
errorMessage = "Failure getting updated group data.";
|
|
||||||
std::cerr << __PRETTY_FUNCTION__ << " Error! " << errorMessage
|
|
||||||
<< std::endl;
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
channelId = channel.mMeta.mGroupId;
|
channelId = channel.mMeta.mGroupId;
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user