Error Handling

Comprehensive error handling patterns for the Extended Markdown ADF Parser library.

Overview

The library provides robust error handling mechanisms for both parsing directions (Markdown ↔ ADF) with support for strict and graceful error recovery modes.

Basic Parser Error Handling

Configuration

const parser = new MarkdownParser({ 
  tokenizer: { strict: false },  // Enable error recovery
  astBuilder: { strict: false }
});

try {
  const adf = parser.parse(malformedMarkdown);
  // Graceful degradation in non-strict mode
} catch (error) {
  console.error('Parsing failed:', error.message);
  // Handle error appropriately
}

Enhanced Parser Error Handling

Async Error Handling

Validation Before Parsing

ADF to Markdown Error Handling

With Recovery Mode

Configuration Options

Common Error Patterns

Invalid Markdown

Validation with Error Reporting

Batch Processing with Error Handling

Debug Mode

Detailed Error Reporting

Troubleshooting

Memory Usage Issues

Enhanced parser uses more memory due to unified/remark ecosystem:

  • Solution: Use basic parser for high-volume processing

  • Monitor: Memory usage in production environments

Performance Issues

Enhanced parser is slower due to additional features:

  • Solution: Profile your specific use case

  • Consider: Hybrid approach (basic for simple, enhanced for complex)

Async/Sync Mismatch

Enhanced parser's main method is async:

  • Solution: Use parseSync() for synchronous operation

  • Be aware: Some features may be limited in sync mode

Last updated