Skip to content

Improve error handling in installPowerPoint function #6

@jozefizso

Description

@jozefizso

Problem

The installPowerPoint() function only captures the exit code when installation fails, making it difficult to debug issues.

Current code (src/index.js:82-84):

const exitCode = await exec.exec('sudo', ['installer', '-pkg', installerPath, '-target', '/Applications']);
if (exitCode !== 0) {
  throw new Error(`Microsoft PowerPoint installation failed with code ${exitCode}.`);
}

When installation fails, users only see:

Error: Microsoft PowerPoint installation failed with code 1.

This provides no information about why the installation failed.

Solution

Capture stdout and stderr to provide better error context:

const { exitCode, stdout, stderr } = await exec.getExecOutput(
  'sudo',
  ['installer', '-pkg', installerPath, '-target', '/'],
  { ignoreReturnCode: true }
);

if (exitCode !== 0) {
  const errorOutput = stderr || stdout || '(no output)';
  throw new Error(
    `Microsoft PowerPoint installation failed with code ${exitCode}.\n${errorOutput.trim()}`
  );
}

Benefits

  • Users get actionable error messages
  • Easier to diagnose installation failures
  • Consistent with error handling used in enableUiAutomation() (src/index.js:110-118)

Priority

Should be fixed before v1.0.0 to improve user experience when troubleshooting issues.

Additional Considerations

Consider adding similar improvements to other exec calls:

  • readPlistValue() at src/index.js:226
  • Any other exec calls that don't capture output

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions