Sha256: 4f420863704245f68f01e570f23b5f250955aa3a70152fe026c073b023a49330
Contents?: true
Size: 1.12 KB
Versions: 13
Compression:
Stored size: 1.12 KB
Contents
from inspect import signature from javonet.core.handler.AbstractCommandHandler import * class CreateClassInstanceHandler(AbstractCommandHandler): def __init__(self): self._required_parameters_count = 1 def process(self, command): try: if len(command.payload) < self._required_parameters_count: raise Exception("CreateClassInstanceHandler parameters mismatch!") clazz = command.payload[0] if len(command.payload) > 1: method_arguments = command.payload[1:] sig = signature(clazz) if len(sig.parameters) != len(method_arguments): raise Exception("Number of arguments for create class instance are not matching!") try: return clazz(*method_arguments) except: raise Exception("Error while creating class instance!") return clazz() except Exception as e: exc_type, exc_value = type(e), e new_exc = exc_type(exc_value).with_traceback(e.__traceback__) raise new_exc from None
Version data entries
13 entries across 8 versions & 1 rubygems