How to use the janus.janus.ErrorMessage.from_exception function in janus

To help you get started, we’ve selected a few janus examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github xamoom / xamoom-janus / janus / decorators.py View on Github external
else:
                                self.meta.update(response_obj.meta)

                        message = JsonApiMessage(data=data,included=included,meta=self.meta,do_nesting=self.nest_in_responses).to_json() #render json response

                        #caching
                        if self.cached_set_hook != None and loaded_from_cache == False:
                            janus_logger.debug("Caching message")
                            self.cached_set_hook(response_obj,message)

                    if self.before_send_hook != None: #fire before send hook
                        self.before_send_hook(self.success_status,message,response_obj)

                    return message
            except Exception as e:
                err_msg = ErrorMessage.from_exception(e)
                tb = traceback.format_exc()

                if self.include_traceback_in_errors:
                    if err_msg.meta == None: err_msg.meta = {}
                    err_msg.traceback = tb

                if self.error_hook != None:
                    self.error_hook(int(err_msg.status),err_msg,tb)

                message = JsonApiMessage(errors=err_msg,meta=self.meta).to_json()

                janus_logger.error("Traceback: " + tb)

                return message