Sha256: 0576d2e1bc218a60f000a8120f3b3ee82b849202d6194b35925b06b963990ec3

Contents?: true

Size: 1.22 KB

Versions: 25

Compression:

Stored size: 1.22 KB

Contents

const Handler = require('./Handler')
const Command = require('../../utils/Command')

class AbstractHandler {
    constructor() {
        if(new.target === AbstractHandler)
            throw new TypeError('You cannot instantiate abstract class')
    }

    process(command) {
        throw new Error('process must be implemented')
    }

    handleCommand(command) {
        this.iterate(command)
        return this.process(command)
    }

    iterate(cmd) {
        for(let i = 0; i < cmd.payload.length; i++) {
            
            if(cmd.payload[i] instanceof Command) {
                let inner = cmd.payload[i]
                cmd.payload[i] = Handler.handlers[inner.commandType].handleCommand(inner)
            }
        }
    }

    process_stack_trace(error, class_name) {
        let stackTraceArray = error.stack.split('\n').map(frame => frame.trim());
        stackTraceArray.forEach((str, index) => {
            if (str.includes(class_name)) {
                stackTraceArray = stackTraceArray.slice(0, index).filter((s) => !s.includes(class_name));
            }
        });
        error.stack = stackTraceArray.join(" \n ")
        return error
    }
}

module.exports = AbstractHandler

Version data entries

25 entries across 25 versions & 1 rubygems

Version Path
javonet-ruby-sdk-2.4.10 lib/javonet-ruby-sdk/Binaries/Nodejs/Windows/X64/core/handler/AbstractHandler.js
javonet-ruby-sdk-2.4.9 lib/javonet-ruby-sdk/Binaries/Nodejs/Windows/X64/core/handler/AbstractHandler.js
javonet-ruby-sdk-2.4.8 lib/javonet-ruby-sdk/Binaries/Nodejs/Windows/X64/core/handler/AbstractHandler.js
javonet-ruby-sdk-2.4.7 lib/javonet-ruby-sdk/Binaries/Nodejs/Windows/X64/core/handler/AbstractHandler.js
javonet-ruby-sdk-2.4.6 lib/javonet-ruby-sdk/Binaries/Nodejs/Windows/X64/core/handler/AbstractHandler.js
javonet-ruby-sdk-2.4.5 lib/javonet-ruby-sdk/Binaries/Nodejs/Windows/X64/core/handler/AbstractHandler.js
javonet-ruby-sdk-2.4.4 lib/javonet-ruby-sdk/Binaries/Nodejs/Windows/X64/core/handler/AbstractHandler.js
javonet-ruby-sdk-2.4.3 lib/javonet-ruby-sdk/Binaries/Nodejs/Windows/X64/core/handler/AbstractHandler.js
javonet-ruby-sdk-2.4.2 lib/javonet-ruby-sdk/Binaries/Nodejs/Windows/X64/core/handler/AbstractHandler.js
javonet-ruby-sdk-2.3.0 lib/javonet-ruby-sdk/Binaries/Nodejs/Windows/X64/core/handler/AbstractHandler.js
javonet-ruby-sdk-2.2.0 lib/javonet-ruby-sdk/Binaries/Nodejs/Windows/X64/core/handler/AbstractHandler.js
javonet-ruby-sdk-2.1.14 lib/javonet-ruby-sdk/Binaries/Nodejs/Windows/X64/core/handler/AbstractHandler.js
javonet-ruby-sdk-2.1.13 lib/javonet-ruby-sdk/Binaries/Nodejs/Windows/X64/core/handler/AbstractHandler.js
javonet-ruby-sdk-2.1.12 lib/javonet-ruby-sdk/Binaries/Nodejs/Windows/X64/core/handler/AbstractHandler.js
javonet-ruby-sdk-2.1.11 lib/javonet-ruby-sdk/Binaries/Nodejs/Windows/X64/core/handler/AbstractHandler.js
javonet-ruby-sdk-2.1.10 lib/javonet-ruby-sdk/Binaries/Nodejs/Windows/X64/core/handler/AbstractHandler.js
javonet-ruby-sdk-2.1.9 lib/javonet-ruby-sdk/Binaries/Nodejs/Windows/X64/core/handler/AbstractHandler.js
javonet-ruby-sdk-2.1.8 lib/javonet-ruby-sdk/Binaries/Nodejs/Windows/X64/core/handler/AbstractHandler.js
javonet-ruby-sdk-2.1.7 lib/javonet-ruby-sdk/Binaries/Nodejs/Windows/X64/core/handler/AbstractHandler.js
javonet-ruby-sdk-2.1.6 lib/javonet-ruby-sdk/Binaries/Nodejs/Windows/X64/core/handler/AbstractHandler.js