Skip to content

Add assertion text to the thrown exception #629

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jan 8, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 8 additions & 5 deletions Firestore/core/src/firebase/firestore/util/assert_stdio.cc
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,13 @@

#include "Firestore/core/src/firebase/firestore/util/firebase_assert.h"

#include <stdio.h>
#include <stdlib.h>
#include <stdarg.h>

#include <exception>
#include <string>

#include "absl/base/config.h"
#include <absl/base/config.h>

#include "Firestore/core/src/firebase/firestore/util/string_printf.h"

namespace firebase {
Expand All @@ -31,17 +31,20 @@ namespace util {

void FailAssert(const char* file, const char* func, const int line,
const char* format, ...) {
std::string message = StringPrintf("ASSERT: %s(%d) %s: ", file, line, func);
std::string message;
StringAppendF(&message, "ASSERT: %s(%d) %s: ", file, line, func);

va_list args;
va_start(args, format);
StringAppendV(&message, format, args);
va_end(args);

#if ABSL_HAVE_EXCEPTIONS
throw std::logic_error(message);

#else
fprintf(stderr, "%s\n", message.c_str());
abort();
std::terminate();
#endif
}

Expand Down