Sha256: 7f3d6b5def77209b9d0e1c5f99aadbb91cf1c3ea5db6545bad00b2167a21d1eb
Contents?: true
Size: 938 Bytes
Versions: 31
Compression:
Stored size: 938 Bytes
Contents
const AbstractHandler = require("./AbstractHandler"); class SetStaticFieldHandler extends AbstractHandler { requiredParametersCount = 3; constructor() { super(); } process(command) { try { if (command.payload.length < this.requiredParametersCount) { throw new Error("Set static field parameters mismatch"); } const { payload } = command; let [obj, field, value] = payload; if (typeof obj[field] === "undefined") { let fields = Object.keys(obj); let message = `Field ${field} not found in class ${obj.constructor.name}. Available fields:\n`; fields.forEach((fieldIter) => { message += `${fieldIter}\n`; }); throw new Error(message); } obj[field] = value; return 0; } catch (error) { throw this.process_stack_trace(error, this.constructor.name); } } } module.exports = new SetStaticFieldHandler();
Version data entries
31 entries across 20 versions & 1 rubygems