aboutsummaryrefslogtreecommitdiffstats
path: root/lang/js/src/Errors.js
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--lang/js/src/Errors.js13
1 files changed, 6 insertions, 7 deletions
diff --git a/lang/js/src/Errors.js b/lang/js/src/Errors.js
index b22eca73..2a35bc5e 100644
--- a/lang/js/src/Errors.js
+++ b/lang/js/src/Errors.js
@@ -123,7 +123,7 @@ const err_list = {
export function gpgme_error(code = 'GENERIC_ERROR', info){
if (err_list.hasOwnProperty(code)){
if (err_list[code].type === 'error'){
- return Object.freeze(new GPGME_Error(code));
+ return new GPGME_Error(code);
}
if (err_list[code].type === 'warning'){
// eslint-disable-next-line no-console
@@ -131,10 +131,10 @@ export function gpgme_error(code = 'GENERIC_ERROR', info){
}
return null;
} else if (code === 'GNUPG_ERROR'){
- return Object.freeze(new GPGME_Error(code, info));
+ return new GPGME_Error(code, info);
}
else {
- return Object.freeze(new GPGME_Error('GENERIC_ERROR'));
+ return new GPGME_Error('GENERIC_ERROR');
}
}
@@ -148,6 +148,7 @@ export function gpgme_error(code = 'GENERIC_ERROR', info){
*/
class GPGME_Error extends Error{
constructor(code = 'GENERIC_ERROR', msg=''){
+
if (code === 'GNUPG_ERROR' && typeof(msg) === 'string'){
super(msg);
} else if (err_list.hasOwnProperty(code)){
@@ -159,12 +160,10 @@ class GPGME_Error extends Error{
} else {
super(err_list['GENERIC_ERROR'].msg);
}
- this.getCode = function(){
- return code;
- };
+ this._code = code;
}
get code(){
- return this.getCode();
+ return this._code;
}
} \ No newline at end of file