Sha256: 5b66314691f5c686b39db666f9499bca785e32cf3a4113a98a2ad1363d718a33
Contents?: true
Size: 1.01 KB
Versions: 11
Compression:
Stored size: 1.01 KB
Contents
const AbstractHandler = require("./AbstractHandler"); class GetInstanceFieldHandler extends AbstractHandler { requiredParametersCount = 2; constructor() { super(); } process(command) { try { if (command.payload.length < this.requiredParametersCount) { throw new Error("Get Instance Field parameters mismatch"); } const { payload } = command; let instance = payload[0]; let field = payload[1]; let instanceField = instance[field]; if (typeof instanceField === "undefined") { let fields = Object.keys(instance); let message = `Field ${field} not found in object. Available fields:\n`; fields.forEach((fieldIter) => { message += `${fieldIter}\n`; }); throw new Error(message); } else { return instanceField; } } catch (error) { throw this.process_stack_trace(error, this.constructor.name); } } } module.exports = new GetInstanceFieldHandler();
Version data entries
11 entries across 11 versions & 1 rubygems