aboutsummaryrefslogtreecommitdiffstats
path: root/lang/js/src/Errors.js
diff options
context:
space:
mode:
authorMaximilian Krambach <[email protected]>2018-08-20 10:12:43 +0000
committerMaximilian Krambach <[email protected]>2018-08-20 10:12:43 +0000
commit1954d27be86b8e4eb801ca6ddcb670f8cfb149f5 (patch)
tree90183ad8fbc37e440a3f2949e3dc5c1fbc12bacb /lang/js/src/Errors.js
parentjs: decode arriving gpg message strings (diff)
downloadgpgme-1954d27be86b8e4eb801ca6ddcb670f8cfb149f5.tar.gz
gpgme-1954d27be86b8e4eb801ca6ddcb670f8cfb149f5.zip
js: revert changes to class read/write restriction
-- * undoes 94ee0988d4eaac27785de6efb7c19ca9976e1e9c and e16a87e83910ebb6bfdc4148369165f121f0997e. I do not fully understand why my approach was bad, but I am not in a position to argue. This revert was requested to me after a review, and I'm doing it in the assumption that more experienced people know better than me. * unittests: Also changed some outdated tests that stopped working since 754e799d35fd62d7a979452f44342934659908c7 (as GPGME_Key is not exported, one cannot check for instanceof in the tests anymore)
Diffstat (limited to 'lang/js/src/Errors.js')
-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