aboutsummaryrefslogtreecommitdiffhomepage
path: root/nuldoc-src/slide/parse.ts
blob: 00ff645f4f76f1b58e5f52ca2f7ac6e5a19b1ac2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
import { Config } from "../config.ts";
import { parseXmlFile } from "../xml.ts";
import { SlideError, XmlParseError } from "../errors.ts";
import { createNewSlideFromRootElement, Slide } from "./slide.ts";

export async function parseSlideFile(
  filePath: string,
  config: Config,
): Promise<Slide> {
  try {
    const root = await parseXmlFile(filePath);
    return createNewSlideFromRootElement(root, filePath, config);
  } catch (e) {
    if (e instanceof SlideError || e instanceof XmlParseError) {
      e.message = `${e.message} in ${filePath}`;
    }
    throw e;
  }
}