Fix issues with defect custom field data

Signed-off-by: Marius David Wieschollek's avatarMarius David Wieschollek <passwords.public@mdns.eu>
parent b4ffaf35
......@@ -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)})
}
......
......@@ -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([]);
}
......
......@@ -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
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment