Source code

Revision control

Other Tools

1
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2
/* vim: set ts=8 sts=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(...) \
15
do { \
16
nsPrintfCString s(__VA_ARGS__); \
17
mozilla::dom::indexedDB::ReportInternalError(__FILE__, __LINE__, s.get()); \
18
NS_WARNING(s.get()); \
19
} while (0)
20
21
#define IDB_REPORT_INTERNAL_ERR() \
22
mozilla::dom::indexedDB::ReportInternalError(__FILE__, __LINE__, "UnknownErr")
23
24
// Based on NS_ENSURE_TRUE
25
#define IDB_ENSURE_TRUE(x, ret) \
26
do { \
27
if (MOZ_UNLIKELY(!(x))) { \
28
IDB_REPORT_INTERNAL_ERR(); \
29
NS_WARNING("IDB_ENSURE_TRUE(" #x ") failed"); \
30
return ret; \
31
} \
32
} while (0)
33
34
// Based on NS_ENSURE_SUCCESS
35
#define IDB_ENSURE_SUCCESS(res, ret) \
36
do { \
37
nsresult __rv = res; /* Don't evaluate |res| more than once */ \
38
if (NS_FAILED(__rv)) { \
39
IDB_REPORT_INTERNAL_ERR(); \
40
NS_ENSURE_SUCCESS_BODY(res, ret) \
41
return ret; \
42
} \
43
} while (0)
44
45
namespace mozilla {
46
namespace dom {
47
namespace indexedDB {
48
49
void ReportInternalError(const char* aFile, uint32_t aLine, const char* aStr);
50
51
} // namespace indexedDB
52
} // namespace dom
53
} // namespace mozilla
54
55
#endif // mozilla_dom_indexeddb_reportinternalerror_h__