Files
tubestation/netwerk/base/nsIURIMutatorUtils.cpp
Valentin Gosu 06b84f67f7 Bug 1433958 - Make NS_MutateURI methods warn immediately after calling method that fails r=mayhemer
Calling NS_ENSURE_SUCCESS at the begining of the methods shows the error in the console, but what we really care about is where the error code comes from. So it is best to use if (NS_FAILED(mStatus) {} at the begining of the methods, and NS_ENSURE_SUCCESS right after calling the appropriate method on mMutator.

MozReview-Commit-ID: 5vVuHk3N4FU
2018-02-26 20:43:45 +01:00

25 lines
589 B
C++

#include "nsIURIMutator.h"
#include "nsIURI.h"
#include "nsComponentManagerUtils.h"
static nsresult
GetURIMutator(nsIURI* aURI, nsIURIMutator** aMutator)
{
if (NS_WARN_IF(!aURI)) {
return NS_ERROR_INVALID_ARG;
}
return aURI->Mutate(aMutator);
}
NS_MutateURI::NS_MutateURI(nsIURI* aURI)
{
mStatus = GetURIMutator(aURI, getter_AddRefs(mMutator));
NS_ENSURE_SUCCESS_VOID(mStatus);
}
NS_MutateURI::NS_MutateURI(const char * aContractID)
{
mMutator = do_CreateInstance(aContractID, &mStatus);
MOZ_ASSERT(NS_SUCCEEDED(mStatus), "Called with wrong aContractID");
}