How to use the @jupyterlab/services.KernelMessage.isErrorMsg function in @jupyterlab/services

To help you get started, we’ve selected a few @jupyterlab/services 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 pbugnion / ipywidgets_server / js / WidgetApplication.js View on Github external
execution.onIOPub = (msg) => {
            // If we have a display message, display the widget.
            if (KernelMessage.isDisplayDataMsg(msg)) {
                let widgetData = msg.content.data['application/vnd.jupyter.widget-view+json'];
                if (widgetData !== undefined && widgetData.version_major === 2) {
                    let model = manager.get_model(widgetData.model_id);
                    if (model !== undefined) {
                        model.then(model => {
                            manager.display_model(msg, model);
                        });
                    }
                }
            }
            else if (KernelMessage.isErrorMsg(msg)) {
                // Show errors to help with debugging
                errorView.showError(msg.content)
            }
        }
    }
github jupyterlab / jupyterlab / tests / test-services / src / kernel / messages.spec.ts View on Github external
it('should check for an message type', () => {
      let msg = KernelMessage.createMessage({
        msgType: 'error',
        channel: 'iopub',
        session: 'baz',
        content: {
          ename: '',
          evalue: '',
          traceback: []
        }
      });
      expect(KernelMessage.isErrorMsg(msg)).to.equal(true);
      expect(KernelMessage.isErrorMsg(iopubStatusMsg)).to.equal(false);
    });
  });
github jupyterlab / jupyterlab-data-explorer / tests / test-services / src / kernel / messages.spec.ts View on Github external
it('should check for an message type', () => {
      let msg = KernelMessage.createMessage({
        msgType: 'error',
        channel: 'iopub',
        session: 'baz',
        content: {
          ename: '',
          evalue: '',
          traceback: []
        }
      });
      expect(KernelMessage.isErrorMsg(msg)).to.equal(true);
      expect(KernelMessage.isErrorMsg(iopubStatusMsg)).to.equal(false);
    });
  });
github jupyterlab / jupyterlab / tests / test-services / src / kernel / messages.spec.ts View on Github external
it('should check for an message type', () => {
      let msg = KernelMessage.createMessage({
        msgType: 'error',
        channel: 'iopub',
        session: 'baz',
        content: {
          ename: '',
          evalue: '',
          traceback: []
        }
      });
      expect(KernelMessage.isErrorMsg(msg)).to.equal(true);
      expect(KernelMessage.isErrorMsg(iopubStatusMsg)).to.equal(false);
    });
  });
github jupyterlab / jupyterlab-data-explorer / tests / test-services / src / kernel / messages.spec.ts View on Github external
it('should check for an message type', () => {
      let msg = KernelMessage.createMessage({
        msgType: 'error',
        channel: 'iopub',
        session: 'baz',
        content: {
          ename: '',
          evalue: '',
          traceback: []
        }
      });
      expect(KernelMessage.isErrorMsg(msg)).to.equal(true);
      expect(KernelMessage.isErrorMsg(iopubStatusMsg)).to.equal(false);
    });
  });
github jupyterlab / jupyterlab / packages / outputconsole-extension / src / index.ts View on Github external
(_, msg: KernelMessage.IIOPubMessage) => {
            if (
              KernelMessage.isDisplayDataMsg(msg) ||
              KernelMessage.isStreamMsg(msg) ||
              KernelMessage.isErrorMsg(msg)
            ) {
              log.log((msg.content as unknown) as nbformat.IOutput);
            }
          }
        );
github jupyterlab / jupyterlab / packages / logconsole-extension / src / nboutput.ts View on Github external
) {
      if (
        KernelMessage.isDisplayDataMsg(msg) ||
        KernelMessage.isStreamMsg(msg) ||
        KernelMessage.isErrorMsg(msg) ||
        KernelMessage.isExecuteResultMsg(msg)
      ) {
        const logger = loggerRegistry.getLogger(nb.context.path);
        logger.rendermime = nb.content.rendermime;
        const data: nbformat.IOutput = {
          ...msg.content,
          output_type: msg.header.msg_type
        };
        let level: LogLevel = levelNormal;
        if (
          KernelMessage.isErrorMsg(msg) ||
          (KernelMessage.isStreamMsg(msg) && msg.content.name === 'stderr')
        ) {
          level = levelError;
        }
        logger.log({ type: 'output', data, level });
      }
    }
github JovianML / jovian-py / jovian / jovian-jupyter-lab-extension / src / NBKernel.ts View on Github external
result.onIOPub = msg => {
            if (KernelMessage.isErrorMsg(msg)) {
              reject(msg.content);
            } else if (KernelMessage.isStreamMsg(msg)) {
              text += msg.content.text + "\n";
            } else if (KernelMessage.isStatusMsg(msg)) {
              if (msg.content.execution_state.toLowerCase() == "idle") {
                resolve(text);
              }
            }
          };
        });
github jupyterlab / jupyterlab / packages / logconsole-extension / src / nboutput.ts View on Github external
function logOutput(
      msg: KernelMessage.IIOPubMessage,
      levelNormal: LogLevel,
      levelError: LogLevel
    ) {
      if (
        KernelMessage.isDisplayDataMsg(msg) ||
        KernelMessage.isStreamMsg(msg) ||
        KernelMessage.isErrorMsg(msg) ||
        KernelMessage.isExecuteResultMsg(msg)
      ) {
        const logger = loggerRegistry.getLogger(nb.context.path);
        logger.rendermime = nb.content.rendermime;
        const data: nbformat.IOutput = {
          ...msg.content,
          output_type: msg.header.msg_type
        };
        let level: LogLevel = levelNormal;
        if (
          KernelMessage.isErrorMsg(msg) ||
          (KernelMessage.isStreamMsg(msg) && msg.content.name === 'stderr')
        ) {
          level = levelError;
        }
        logger.log({ type: 'output', data, level });