Skip to content

Improve error handling #5

Description

@humphd

In https://github.com/tcvan0707/txt2html/blob/main/src/txt2html.js#L57-L61, I would improve things slightly:

// Move to its own function
function ensureDistDir() {
    try {
        await fs.mkdir(distDir);
    } catch {
        console.error(`Couldn't create ${distDir}, exiting`);
        process.exit(1);
    }
}

// later on call this...
ensureDistDir();

Here I log a helpful error message, don't print a call stack, and exit with an error code.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions