function generate() {
          let text;
          let generateModel = model;
          try {
            text = generator(workspace);
          } catch (e) {
            console.error(e);
            text = e.message;
            generateModel = errorModel;
            editor.updateOptions({
              wordWrap: true,
            });
          }
          if (
            generateModel.getValue() === text &&
            editor.getModel() === generateModel
          ) {
            return;
          }
          generateModel.pushEditOperations(
            [],
            [{range: generateModel.getFullModelRange(), text}],
            () => null,
          );
          editor.setModel(generateModel);
          editor.setSelection(new window.monaco.Range(0, 0, 0, 0));
        }
Call the generator, displaying an error message if it fails.