aboutsummaryrefslogtreecommitdiffstats
path: root/lang/js/src/Errors.js
diff options
context:
space:
mode:
authorMaximilian Krambach <[email protected]>2019-06-19 10:57:20 +0000
committerMaximilian Krambach <[email protected]>2019-06-19 10:58:44 +0000
commitf5e27a12d3fd22b95e83c03a5650659bfa2299b9 (patch)
tree7ddac98f4f0a20ffc6d6a2aaf2ec25ddd5a7efd3 /lang/js/src/Errors.js
parentPost release updates (diff)
downloadgpgme-f5e27a12d3fd22b95e83c03a5650659bfa2299b9.tar.gz
gpgme-f5e27a12d3fd22b95e83c03a5650659bfa2299b9.zip
js: Error handling for browser errors
-- * Connection.js - Add some meaningful nativeMessaging feedback for failing communication due to misconfiguration or other browser-originated fails - add an "isDisconnected" property - "isNativeHostUnknown" tries to match browser's feedback string if the browser does not find gpgme-json * init.js - initialization will now reject with a more meaningful error if the configuration is not set up or other browser-based errors (chrome.runtime.lastError) are present. This should speed up the normal initialization (not having to waiting for a timeout any more in case of improper setup) * errors.js - CONN_NATIVEMESSAGE: New error that passes the browser's nativeMessaging error - CONN_NO_CONFIG: native messaging error indicating that the nativeMessaging host was not set up properly * unittests.js: - added the "isDisconnected" property to the startup tests - added tests for proper behavior of connection checks
Diffstat (limited to 'lang/js/src/Errors.js')
-rw-r--r--lang/js/src/Errors.js12
1 files changed, 10 insertions, 2 deletions
diff --git a/lang/js/src/Errors.js b/lang/js/src/Errors.js
index bf52cce7..6189414f 100644
--- a/lang/js/src/Errors.js
+++ b/lang/js/src/Errors.js
@@ -35,6 +35,14 @@ export const err_list = {
msg: 'The nativeMessaging answer was empty.',
type: 'error'
},
+ 'CONN_NO_CONFIG':{
+ msg: 'The browser does not recognize the nativeMessaging host.',
+ type: 'error'
+ },
+ 'CONN_NATIVEMESSAGE':{
+ msg: 'The native messaging was not successful.',
+ type: 'error'
+ },
'CONN_TIMEOUT': {
msg: 'A connection timeout was exceeded.',
type: 'error'
@@ -156,8 +164,8 @@ 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'){
+ const verboseErrors = ['GNUPG_ERROR', 'CONN_NATIVEMESSAGE'];
+ if (verboseErrors.includes(code) && typeof (msg) === 'string'){
super(msg);
} else if (err_list.hasOwnProperty(code)){
if (msg){