@@ -56,40 +56,56 @@ using v8::Value; |
56 | 56 | } \ |
57 | 57 | } while (0) |
58 | 58 |
|
59 | | -inline Local<Object> CreateSQLiteError(Isolate* isolate, const char* message) { |
60 | | - Local<String> js_msg = String::NewFromUtf8(isolate, message).ToLocalChecked(); |
61 | | - Local<Object> e = Exception::Error(js_msg) |
62 | | - ->ToObject(isolate->GetCurrentContext()) |
63 | | - .ToLocalChecked(); |
64 | | - e->Set(isolate->GetCurrentContext(), |
65 | | - OneByteString(isolate, "code"), |
66 | | - OneByteString(isolate, "ERR_SQLITE_ERROR")) |
67 | | - .Check(); |
| 59 | +inline MaybeLocal<Object> CreateSQLiteError(Isolate* isolate, |
| 60 | + const char* message) { |
| 61 | + Local<String> js_msg; |
| 62 | + Local<Object> e; |
| 63 | + if (!String::NewFromUtf8(isolate, message).ToLocal(&js_msg) || |
| 64 | + !Exception::Error(js_msg) |
| 65 | + ->ToObject(isolate->GetCurrentContext()) |
| 66 | + .ToLocal(&e) || |
| 67 | + e->Set(isolate->GetCurrentContext(), |
| 68 | + OneByteString(isolate, "code"), |
| 69 | + OneByteString(isolate, "ERR_SQLITE_ERROR")) |
| 70 | + .IsNothing()) { |
| 71 | + return MaybeLocal<Object>(); |
| 72 | + } |
68 | 73 | return e; |
69 | 74 | } |
70 | 75 |
|
71 | | -inline Local<Object> CreateSQLiteError(Isolate* isolate, sqlite3* db) { |
| 76 | +inline MaybeLocal<Object> CreateSQLiteError(Isolate* isolate, sqlite3* db) { |
72 | 77 | int errcode = sqlite3_extended_errcode(db); |
73 | 78 | const char* errstr = sqlite3_errstr(errcode); |
74 | 79 | const char* errmsg = sqlite3_errmsg(db); |
75 | | - Local<Object> e = CreateSQLiteError(isolate, errmsg); |
76 | | - e->Set(isolate->GetCurrentContext(), |
77 | | - OneByteString(isolate, "errcode"), |
78 | | - Integer::New(isolate, errcode)) |
79 | | - .Check(); |
80 | | - e->Set(isolate->GetCurrentContext(), |
81 | | - OneByteString(isolate, "errstr"), |
82 | | - String::NewFromUtf8(isolate, errstr).ToLocalChecked()) |
83 | | - .Check(); |
| 80 | + Local<String> js_errmsg; |
| 81 | + Local<Object> e; |
| 82 | + if (!String::NewFromUtf8(isolate, errstr).ToLocal(&js_errmsg) || |
| 83 | + !CreateSQLiteError(isolate, errmsg).ToLocal(&e) || |
| 84 | + e->Set(isolate->GetCurrentContext(), |
| 85 | + OneByteString(isolate, "errcode"), |
| 86 | + Integer::New(isolate, errcode)) |
| 87 | + .IsNothing() || |
| 88 | + e->Set(isolate->GetCurrentContext(), |
| 89 | + OneByteString(isolate, "errstr"), |
| 90 | + js_errmsg) |
| 91 | + .IsNothing()) { |
| 92 | + return MaybeLocal<Object>(); |
| 93 | + } |
84 | 94 | return e; |
85 | 95 | } |
86 | 96 |
|
87 | 97 | inline void THROW_ERR_SQLITE_ERROR(Isolate* isolate, sqlite3* db) { |
88 | | - isolate->ThrowException(CreateSQLiteError(isolate, db)); |
| 98 | + Local<Object> e; |
| 99 | + if (CreateSQLiteError(isolate, db).ToLocal(&e)) { |
| 100 | + isolate->ThrowException(e); |
| 101 | + } |
89 | 102 | } |
90 | 103 |
|
91 | 104 | inline void THROW_ERR_SQLITE_ERROR(Isolate* isolate, const char* message) { |
92 | | - isolate->ThrowException(CreateSQLiteError(isolate, message)); |
| 105 | + Local<Object> e; |
| 106 | + if (CreateSQLiteError(isolate, message).ToLocal(&e)) { |
| 107 | + isolate->ThrowException(e); |
| 108 | + } |
93 | 109 | } |
94 | 110 |
|
95 | 111 | DatabaseSync::DatabaseSync(Environment* env, |
|