Use THROW_FORMAT

This commit is contained in:
Huntereb 2019-12-10 23:11:34 -05:00
parent b175770afa
commit 49bb3e6800
8 changed files with 20 additions and 19 deletions

View File

@ -61,7 +61,7 @@ namespace tin::install
catch (std::runtime_error& e)
{
serviceClose(&contentMetaDatabase.s);
throw e;
THROW_FORMAT(e.what());
}
serviceClose(&contentMetaDatabase.s);
@ -80,7 +80,7 @@ namespace tin::install
// 0x410: The record doesn't already exist
if (R_FAILED(rc = nsCountApplicationContentMeta(baseTitleId, &contentMetaCount)) && rc != 0x410)
{
throw std::runtime_error("Failed to count application content meta");
THROW_FORMAT("Failed to count application content meta");
}
rc = 0;
@ -98,7 +98,7 @@ namespace tin::install
if (entriesRead != contentMetaCount)
{
throw std::runtime_error("Mismatch between entries read and content meta count");
THROW_FORMAT("Mismatch between entries read and content meta count");
}
memcpy(storageRecords.data(), contentStorageBuf.get(), contentStorageBufSize);

View File

@ -102,7 +102,7 @@ namespace tin::install::nsp
ncaName += ".cnmt.ncz";
else
{
throw std::runtime_error(("Failed to find NCA file " + ncaName + ".nca/.cnmt.nca/.ncz/.cnmt.ncz").c_str());
THROW_FORMAT(("Failed to find NCA file " + ncaName + ".nca/.cnmt.nca/.ncz/.cnmt.ncz").c_str());
}
LOG_DEBUG("NcaId: %s\n", ncaName.c_str());
@ -148,7 +148,7 @@ namespace tin::install::nsp
auto readBuffer = std::make_unique<u8[]>(readSize);
if (readBuffer == NULL)
throw std::runtime_error(("Failed to allocate read buffer for " + ncaName).c_str());
THROW_FORMAT(("Failed to allocate read buffer for " + ncaName).c_str());
LOG_DEBUG("Size: 0x%lx\n", ncaSize);

View File

@ -147,7 +147,7 @@ namespace tin::install::nsp
if (tikFileEntry == nullptr)
{
LOG_DEBUG("Remote tik file is missing.\n");
throw std::runtime_error("Remote tik file is not present!");
THROW_FORMAT("Remote tik file is not present!");
}
u64 tikSize = tikFileEntry->fileSize;
@ -161,7 +161,7 @@ namespace tin::install::nsp
if (certFileEntry == nullptr)
{
LOG_DEBUG("Remote cert file is missing.\n");
throw std::runtime_error("Remote cert file is not present!");
THROW_FORMAT("Remote cert file is not present!");
}
u64 certSize = certFileEntry->fileSize;

View File

@ -153,7 +153,7 @@ namespace tin::install::xci
if (tikFileEntries[i] == nullptr)
{
LOG_DEBUG("Remote tik file is missing.\n");
throw std::runtime_error("Remote tik file is not present!");
THROW_FORMAT("Remote tik file is not present!");
}
u64 tikSize = tikFileEntries[i]->fileSize;
@ -164,7 +164,7 @@ namespace tin::install::xci
if (certFileEntries[i] == nullptr)
{
LOG_DEBUG("Remote cert file is missing.\n");
throw std::runtime_error("Remote cert file is not present!");
THROW_FORMAT("Remote cert file is not present!");
}
u64 certSize = certFileEntries[i]->fileSize;

View File

@ -38,7 +38,7 @@ namespace nx::ncm
m_bytes(size)
{
if (size < sizeof(PackagedContentMetaHeader))
throw std::runtime_error("Content meta data size is too small!");
THROW_FORMAT("Content meta data size is too small!");
m_bytes.Resize(size);
memcpy(m_bytes.GetData(), data, size);

View File

@ -47,7 +47,7 @@ namespace nx::fs
if (sizeRead != size)
{
std::string msg = "Size read " + std::string("" + sizeRead) + " doesn't match expected size " + std::string("" + size);
throw std::runtime_error(msg.c_str());
THROW_FORMAT(msg.c_str());
}
}
@ -78,7 +78,7 @@ namespace nx::fs
/*if (entriesRead != numEntries)
{
std::string msg = "Entries read " + std::string("" + entriesRead) + " doesn't match expected number " + std::string("" + numEntries);
throw std::runtime_error(msg);
THROW_FORMAT(msg);
}*/
}
@ -108,7 +108,7 @@ namespace nx::fs
{
Result rc = 0;
if (path.length() >= FS_MAX_PATH)
throw std::runtime_error("Directory path is too long!");
THROW_FORMAT("Directory path is too long!");
// libnx expects a FS_MAX_PATH-sized buffer
path.reserve(FS_MAX_PATH);
@ -130,7 +130,7 @@ namespace nx::fs
IFile IFileSystem::OpenFile(std::string path)
{
if (path.length() >= FS_MAX_PATH)
throw std::runtime_error("Directory path is too long!");
THROW_FORMAT("Directory path is too long!");
// libnx expects a FS_MAX_PATH-sized buffer
path.reserve(FS_MAX_PATH);
@ -144,7 +144,7 @@ namespace nx::fs
{
// Account for null at the end of c strings
if (path.length() >= FS_MAX_PATH)
throw std::runtime_error("Directory path is too long!");
THROW_FORMAT("Directory path is too long!");
// libnx expects a FS_MAX_PATH-sized buffer
path.reserve(FS_MAX_PATH);

View File

@ -428,7 +428,7 @@ u64 NcaWriter::write(const u8* ptr, u64 sz)
}
else
{
throw std::runtime_error("not enough data to read ncz header");
THROW_FORMAT("not enough data to read ncz header");
}
}
@ -438,7 +438,7 @@ u64 NcaWriter::write(const u8* ptr, u64 sz)
}
else
{
throw std::runtime_error("null writer");
THROW_FORMAT("null writer");
}
}
@ -462,7 +462,7 @@ void NcaWriter::flushHeader()
}
else
{
throw std::runtime_error("Invalid NCA magic");
THROW_FORMAT("Invalid NCA magic");
}
if (header.distribution == 1)

View File

@ -2,6 +2,7 @@
#include <string.h>
#include <mbedtls/bignum.h>
#include <stdexcept>
#include "util/error.hpp"
void Crypto::calculateMGF1andXOR(unsigned char* data, size_t data_size, const void* source, size_t source_size) {
unsigned char h_buf[RSA_2048_BYTES] = {0};
@ -45,7 +46,7 @@ bool Crypto::rsa2048PssVerify(const void *data, size_t len, const unsigned char
mbedtls_mpi_exp_mod(&message_mpi, &signature_mpi, &e_mpi, &modulus_mpi, NULL);
if (mbedtls_mpi_write_binary(&message_mpi, m_buf, RSA_2048_BYTES) != 0) {
throw std::runtime_error("Failed to export exponentiated RSA message!");
THROW_FORMAT("Failed to export exponentiated RSA message!");
}
mbedtls_mpi_free(&signature_mpi);