diff options
author | Marius David Wieschollek <passwords.public@mdns.eu> | 2021-01-09 02:30:29 +0300 |
---|---|---|
committer | Marius David Wieschollek <passwords.public@mdns.eu> | 2021-01-09 02:30:29 +0300 |
commit | d59dff14b9f35adb4d84090f5684c96afbab2a5b (patch) | |
tree | 224ec2d191d49ab213a6b40eedc3a3bc79948f22 /src | |
parent | b4ffaf3571fa323e3402a05b4887b195cd89d3f1 (diff) |
Fix issues with defect custom field data
Signed-off-by: Marius David Wieschollek <passwords.public@mdns.eu>
Diffstat (limited to 'src')
-rw-r--r-- | src/Converter/CustomFieldConverter.js | 2 | ||||
-rw-r--r-- | src/Converter/PasswordConverter.js | 8 | ||||
-rw-r--r-- | src/Logger/Logger.js | 37 |
3 files changed, 40 insertions, 7 deletions
diff --git a/src/Converter/CustomFieldConverter.js b/src/Converter/CustomFieldConverter.js index 2515611..9ab2ff7 100644 --- a/src/Converter/CustomFieldConverter.js +++ b/src/Converter/CustomFieldConverter.js @@ -32,7 +32,7 @@ export default class CustomFieldConverter { */ fromObject(object) { if(!object.hasOwnProperty('type') || object.type === null || object.type === undefined) { - this._client.getLogger().warning('Ignoring invalid custom field data', {field: object}); + this._client.getLogger().error('Found invalid custom field', {field: object}); this._client.getClass(`model.defectField`, {label:'##ERROR##', value:JSON.stringify(object)}) } diff --git a/src/Converter/PasswordConverter.js b/src/Converter/PasswordConverter.js index 13e16e5..e2aef20 100644 --- a/src/Converter/PasswordConverter.js +++ b/src/Converter/PasswordConverter.js @@ -21,7 +21,13 @@ export default class PasswordConverter extends AbstractConverter { let clone = ObjectClone.clone(object); if(typeof clone.customFields === 'string') { - clone.customFields = this._customFieldConverter.fromJSON(clone.customFields); + try { + clone.customFields = this._customFieldConverter.fromJSON(clone.customFields); + } catch(e) { + this._client.getLogger().warning('Could not read custom fields', {password: object}); + this._client.getLogger().exception(e, {password: object}); + clone.customFields = this._customFieldConverter.fromArray([]); + } } else { clone.customFields = this._customFieldConverter.fromArray([]); } diff --git a/src/Logger/Logger.js b/src/Logger/Logger.js index 646da36..4bb932e 100644 --- a/src/Logger/Logger.js +++ b/src/Logger/Logger.js @@ -24,45 +24,72 @@ export default class Logger { /** * @param {String} message * @param {Object} [context={}] + * + * @returns {Logger} */ debug(message, context = {}) { - if(this._logLevel > 0) return; + if(this._logLevel > 0) return this; console.debug(message, context); + return this; } /** * @param {String} message * @param {Object} [context={}] + * + * @returns {Logger} */ info(message, context = {}) { - if(this._logLevel > 1) return; + if(this._logLevel > 1) return this; console.info(message, context); + return this; } /** * @param {String} message * @param {Object} [context={}] + * + * @returns {Logger} */ log(message, context = {}) { - if(this._logLevel > 2) return; + if(this._logLevel > 2) return this; console.log(message, context); + return this; } /** * @param {String} message * @param {Object} [context={}] + * + * @returns {Logger} */ warning(message, context = {}) { - if(this._logLevel > 3) return; + if(this._logLevel > 3) return this; console.warn(message, context); + return this; } /** * @param {String} message * @param {Object} [context={}] + * + * @returns {Logger} */ error(message, context = {}) { - if(this._logLevel > 4) return; + if(this._logLevel > 4) return this; console.error(message, context); + return this; + } + + /** + * @param {Error} exception + * @param {Object} [context={}] + * + * @returns {Logger} + */ + exception(exception, context = {}) { + if(this._logLevel > 4) return this; + console.error(exception, context); + return this; } }
\ No newline at end of file |