Error handling

View as MarkdownMarkdown

Set up your AI agent

Give your coding agent live access to the GroupDocs documentation and API reference through the GroupDocs Docs MCP server — no install, no API key. Learn more

claude mcp add --transport http groupdocs-docs https://docs.groupdocs.com/mcp

Also process documents locally

The GroupDocs.Markdown MCP server lets your agent work with files on your machine; they are never uploaded. It needs the .NET 10 SDK or Docker.

claude mcp add groupdocs-markdown -- dnx GroupDocs.Markdown.Mcp --yes
Folders, licensing and more →

All convert() methods throw on failure. Catch GroupDocsMarkdownException — it is the base type for everything the library raises:

import com.groupdocs.markdown.*;

public class ErrorHandlingExample {

    public static void main(String[] args) {
        try {
            MarkdownConverter.toFile("annual-report.docx", "error-handling-example.md");
        } catch (GroupDocsMarkdownException e) {
            System.out.println("Conversion failed: " + e.getMessage());
        }
    }
}

annual-report.docx is a sample file used in this example. Click here to download it.

![](data:...;base64,[elided])

**Annual Report 2025**

Meridian Outdoor Co.


# **Table of Contents**

Meridian Outdoor Co.	1
[TRUNCATED]

Download full output

Exception types

ExceptionWhen thrown
DocumentProtectedExceptionDocument is password-protected and no password or wrong password was provided
InvalidFormatExceptionFile is corrupt or has an unrecognized format
GroupDocsMarkdownExceptionGeneral conversion error

All three are unchecked — they extend RuntimeException, so the compiler does not force you to catch or declare them. DocumentProtectedException and InvalidFormatException both extend GroupDocsMarkdownException.

Warning
Catch the base type, not the subtypes. In 26.5 the converter wraps the specific exception inside a GroupDocsMarkdownException rather than letting it propagate, so a catch (DocumentProtectedException e) block never runs — the wrapper carries the original type name in its message instead. Catch GroupDocsMarkdownException and inspect getMessage() to distinguish causes.

Conversion warnings

Non-fatal issues are reported via DocumentConvertResult.getWarnings():

import com.groupdocs.markdown.*;

public class WarningsExample {

    public static void main(String[] args) {
        DocumentConvertOptions options = new DocumentConvertOptions();
        options.setMaxRows(10);

        try (MarkdownConverter converter = new MarkdownConverter("cost-analysis.xlsx")) {
            DocumentConvertResult result = converter.convert("warnings-example.md", options);

            for (String warning : result.getWarnings()) {
                System.out.println("Warning: " + warning);
            }
        }
    }
}

cost-analysis.xlsx is a sample file used in this example. Click here to download it.

## Summary

| Category | FY2024 | FY2025 | FY2026 |
| --- | --- | --- | --- |
| Parts and materials | $1,325,000.00 | $1,480,000.00 | $1,620,000.00 |
| Manufacturing equipment | $900,500.00 | $980,000.00 | $1,050,000.00 |
| Warehousing | $420,000.00 | $510,000.00 | $590,000.00 |
| Shipping | $380,000.00 | $445,000.00 | $520,000.00 |
| Marketing | $250,000.00 | $340,000.00 | $480,000.00 |
| R&D | $180,000.00 | $230,000.00 | $310,000.00 |
[TRUNCATED]

Download full output