|
1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ |
|
2 /* vim: set ts=2 et sw=2 tw=80: */ |
|
3 /* This Source Code Form is subject to the terms of the Mozilla Public |
|
4 * License, v. 2.0. If a copy of the MPL was not distributed with this |
|
5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
|
6 |
|
7 #ifndef mozilla_dom_indexeddb_reportinternalerror_h__ |
|
8 #define mozilla_dom_indexeddb_reportinternalerror_h__ |
|
9 |
|
10 #include "nsDebug.h" |
|
11 |
|
12 #include "IndexedDatabase.h" |
|
13 |
|
14 #define IDB_WARNING(x) \ |
|
15 mozilla::dom::indexedDB::ReportInternalError(__FILE__, __LINE__, x); \ |
|
16 NS_WARNING(x) |
|
17 |
|
18 #define IDB_REPORT_INTERNAL_ERR() \ |
|
19 mozilla::dom::indexedDB::ReportInternalError(__FILE__, __LINE__, \ |
|
20 "UnknownErr") |
|
21 |
|
22 // Based on NS_ENSURE_TRUE |
|
23 #define IDB_ENSURE_TRUE(x, ret) \ |
|
24 do { \ |
|
25 if (MOZ_UNLIKELY(!(x))) { \ |
|
26 IDB_REPORT_INTERNAL_ERR(); \ |
|
27 NS_WARNING("IDB_ENSURE_TRUE(" #x ") failed"); \ |
|
28 return ret; \ |
|
29 } \ |
|
30 } while(0) |
|
31 |
|
32 // Based on NS_ENSURE_SUCCESS |
|
33 #define IDB_ENSURE_SUCCESS(res, ret) \ |
|
34 do { \ |
|
35 nsresult __rv = res; /* Don't evaluate |res| more than once */ \ |
|
36 if (NS_FAILED(__rv)) { \ |
|
37 IDB_REPORT_INTERNAL_ERR(); \ |
|
38 NS_ENSURE_SUCCESS_BODY(res, ret) \ |
|
39 return ret; \ |
|
40 } \ |
|
41 } while(0) |
|
42 |
|
43 |
|
44 BEGIN_INDEXEDDB_NAMESPACE |
|
45 |
|
46 void |
|
47 ReportInternalError(const char* aFile, uint32_t aLine, const char* aStr); |
|
48 |
|
49 END_INDEXEDDB_NAMESPACE |
|
50 |
|
51 #endif // mozilla_dom_indexeddb_reportinternalerror_h__ |