Details
-
Bug
-
Resolution: Fixed
-
Critical
-
7.1.0
-
7.1.0-1858
-
Untriaged
-
1
-
Unknown
Description
With following UDF:
function sp_insert(num) {
|
try { |
var insert = num;
|
var insert_statement = N1QL('INSERT INTO default (KEY, VALUE) VALUES ("k004", {"num_col1": $num })', {'num':num}); |
return "Succeeded to insert " + insert; |
} catch (error) { |
return "Failed: " + error; |
}
|
}
|
N1QL error caught as part of JS udf are simple string e.g.
DML Error, possible causes include concurrent modification. Failed to perform INSERT on key k004 - cause: Key k004 - cause: unable to complete action after 1 attempts: key exists" |
We should provide more granular information in the error object like in cbq:
[
|
{
|
"cause": { |
"caller": "couchbase:1944", |
"code": 5000, |
"icause": "unable to complete action after 1 attempts: key exists", |
"key": "Internal Error", |
"message": "Key k004" |
},
|
"code": 12009, |
"msg": "DML Error, possible causes include concurrent modification. Failed to perform INSERT on key k004 - cause: Key k004 - cause: unable to complete action after 1 attempts: key exists" |
}
|
]
|
Other vendors have this functionality, for example err contains:
err.code
|
err.state
|
err.message
|
err.stackTraceTxt
|