or run

tessl search
Log in

Version

Workspace
tessl
Visibility
Public
Created
Last updated
Describes
npmpkg:npm/marked@17.0.x

docs

index.md
tile.json

tessl/npm-marked

tessl install tessl/npm-marked@17.0.0

A markdown parser built for speed

error-handling.mddocs/guides/

Error Handling Guide

Handle parsing errors gracefully.

Throw Errors (Default)

import { marked } from "marked";

try {
  const html = marked.parse(malformedMarkdown);
} catch (err) {
  console.error('Parse error:', err.message);
}

Silent Mode

import { marked } from "marked";

marked.setOptions({ silent: true });
const html = marked.parse(malformedMarkdown);
// Returns: <p>An error occurred:</p><pre>Error message</pre>

Error Recovery

import { marked } from "marked";

function safeParse(markdown, options = {}) {
  try {
    return {
      success: true,
      html: marked.parse(markdown, { ...options, silent: false }),
      error: null
    };
  } catch (err) {
    return {
      success: false,
      html: marked.parse(markdown, { ...options, silent: true }),
      error: err.message
    };
  }
}

Common Error Scenarios

  • Invalid input type (null/undefined)
  • Malformed tokens (low-level API)
  • Extension errors
  • Async errors

See Troubleshooting Guide for specific issues.