mirror of
https://github.com/The-Low-Code-Foundation/OpenNoodl.git
synced 2026-01-10 14:22:53 +01:00
fix(runtime): JavaScript Records API error handling (#32)
This commit is contained in:
committed by
Richard Osborne
parent
c66ce32449
commit
af81e1304e
@@ -108,6 +108,7 @@ function createRecordsAPI(modelScope) {
|
||||
},
|
||||
|
||||
async fetch(objectOrId, options) {
|
||||
if (typeof objectOrId === 'undefined') return Promise.reject(new Error("'objectOrId' is undefined."));
|
||||
if (typeof objectOrId !== 'string') objectOrId = objectOrId.getId();
|
||||
const className = (options ? options.className : undefined) || (modelScope || Model).get(objectOrId)._class;
|
||||
|
||||
@@ -130,6 +131,7 @@ function createRecordsAPI(modelScope) {
|
||||
},
|
||||
|
||||
async increment(objectOrId, properties, options) {
|
||||
if (typeof objectOrId === 'undefined') return Promise.reject(new Error("'objectOrId' is undefined."));
|
||||
if (typeof objectOrId !== 'string') objectOrId = objectOrId.getId();
|
||||
const className = (options ? options.className : undefined) || (modelScope || Model).get(objectOrId)._class;
|
||||
|
||||
@@ -153,6 +155,7 @@ function createRecordsAPI(modelScope) {
|
||||
},
|
||||
|
||||
async save(objectOrId, properties, options) {
|
||||
if (typeof objectOrId === 'undefined') return Promise.reject(new Error("'objectOrId' is undefined."));
|
||||
if (typeof objectOrId !== 'string') objectOrId = objectOrId.getId();
|
||||
const className = (options ? options.className : undefined) || (modelScope || Model).get(objectOrId)._class;
|
||||
|
||||
@@ -202,6 +205,7 @@ function createRecordsAPI(modelScope) {
|
||||
},
|
||||
|
||||
async delete(objectOrId, options) {
|
||||
if (typeof objectOrId === 'undefined') return Promise.reject(new Error("'objectOrId' is undefined."));
|
||||
if (typeof objectOrId !== 'string') objectOrId = objectOrId.getId();
|
||||
const className = (options ? options.className : undefined) || (modelScope || Model).get(objectOrId)._class;
|
||||
|
||||
@@ -270,7 +274,7 @@ function createRecordsAPI(modelScope) {
|
||||
resolve();
|
||||
},
|
||||
error: (err) => {
|
||||
reject(Error(rr || 'Failed to add relation.'));
|
||||
reject(Error(err || 'Failed to add relation.'));
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user