diff options
author | Maximilian Krambach <[email protected]> | 2018-04-25 08:54:24 +0000 |
---|---|---|
committer | Maximilian Krambach <[email protected]> | 2018-04-25 08:54:24 +0000 |
commit | c72adc00965fe4fcedd9d18609211021a091b28b (patch) | |
tree | af1cc5df7da410f42f2762da9b03b5ca3d39087d /lang/js/src/gpgmejs.js | |
parent | js: allow openpgp-like Message objects as Data (diff) | |
download | gpgme-c72adc00965fe4fcedd9d18609211021a091b28b.tar.gz gpgme-c72adc00965fe4fcedd9d18609211021a091b28b.zip |
js: change in Error behaviour
--
* Error objects will now return the error code if defined as error type
in src/Errors.js, or do a console.log if it is a warning. Errors from
the native gpgme-json will be marked as GNUPG_ERROR.
Diffstat (limited to 'lang/js/src/gpgmejs.js')
-rw-r--r-- | lang/js/src/gpgmejs.js | 13 |
1 files changed, 5 insertions, 8 deletions
diff --git a/lang/js/src/gpgmejs.js b/lang/js/src/gpgmejs.js index 03ed5cb6..b20ff0f2 100644 --- a/lang/js/src/gpgmejs.js +++ b/lang/js/src/gpgmejs.js @@ -95,9 +95,8 @@ export class GpgME { */ decrypt(data){ - if (data === undefined){ - return Promise.reject(new GPGMEJS_Error ('EMPTY_MSG')); + return Promise.reject(GPGMEJS_Error('MSG_EMPTY')); } let msg = new GPGME_Message('decrypt'); putData(msg, data); @@ -106,7 +105,7 @@ export class GpgME { } deleteKey(key, delete_secret = false, no_confirm = false){ - return Promise.reject(new GPGMEJS_Error ('NOT_YET_IMPLEMENTED')); + return Promise.reject(GPGMEJS_Error('NOT_YET_IMPLEMENTED')); let msg = new GPGME_Message('deletekey'); let key_arr = toKeyIdArray(key); if (key_arr.length !== 1){ @@ -127,7 +126,7 @@ export class GpgME { case 'ERR_NO_ERROR': return Promise.resolve('okay'); //TBD default: - return Promise.reject(new GPGMEJS_Error); + return Promise.reject(GPGMEJS_Error('TODO') ); // // INV_VALUE, // GPG_ERR_NO_PUBKEY, // GPG_ERR_AMBIGUOUS_NAME, @@ -146,11 +145,9 @@ export class GpgME { */ function putData(message, data){ if (!message || !message instanceof GPGME_Message ) { - return new GPGMEJS_Error('WRONGPARAM'); + return GPGMEJS_Error('PARAM_WRONG'); } if (!data){ - //TODO Debug only! No data is legitimate - console.log('Warning. no data in message'); message.setParameter('data', ''); } else if (data instanceof Uint8Array){ let decoder = new TextDecoder('utf8'); @@ -167,6 +164,6 @@ function putData(message, data){ message.setParameter ('data', decoder.decode(txt)); } } else { - return new GPGMEJS_Error('WRONGPARAM'); + return GPGMEJS_Error('PARAM_WRONG'); } } |