michael@0: /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ michael@0: /* vim: set ts=2 et sw=2 tw=80: */ michael@0: /* This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: michael@0: #ifndef mozilla_dom_indexeddb_reportinternalerror_h__ michael@0: #define mozilla_dom_indexeddb_reportinternalerror_h__ michael@0: michael@0: #include "nsDebug.h" michael@0: michael@0: #include "IndexedDatabase.h" michael@0: michael@0: #define IDB_WARNING(x) \ michael@0: mozilla::dom::indexedDB::ReportInternalError(__FILE__, __LINE__, x); \ michael@0: NS_WARNING(x) michael@0: michael@0: #define IDB_REPORT_INTERNAL_ERR() \ michael@0: mozilla::dom::indexedDB::ReportInternalError(__FILE__, __LINE__, \ michael@0: "UnknownErr") michael@0: michael@0: // Based on NS_ENSURE_TRUE michael@0: #define IDB_ENSURE_TRUE(x, ret) \ michael@0: do { \ michael@0: if (MOZ_UNLIKELY(!(x))) { \ michael@0: IDB_REPORT_INTERNAL_ERR(); \ michael@0: NS_WARNING("IDB_ENSURE_TRUE(" #x ") failed"); \ michael@0: return ret; \ michael@0: } \ michael@0: } while(0) michael@0: michael@0: // Based on NS_ENSURE_SUCCESS michael@0: #define IDB_ENSURE_SUCCESS(res, ret) \ michael@0: do { \ michael@0: nsresult __rv = res; /* Don't evaluate |res| more than once */ \ michael@0: if (NS_FAILED(__rv)) { \ michael@0: IDB_REPORT_INTERNAL_ERR(); \ michael@0: NS_ENSURE_SUCCESS_BODY(res, ret) \ michael@0: return ret; \ michael@0: } \ michael@0: } while(0) michael@0: michael@0: michael@0: BEGIN_INDEXEDDB_NAMESPACE michael@0: michael@0: void michael@0: ReportInternalError(const char* aFile, uint32_t aLine, const char* aStr); michael@0: michael@0: END_INDEXEDDB_NAMESPACE michael@0: michael@0: #endif // mozilla_dom_indexeddb_reportinternalerror_h__