Skip to content

Normalize exception handling in command classes#993

Merged
dereuromark merged 1 commit into5.xfrom
normalize-exception-handling
Jan 11, 2026
Merged

Normalize exception handling in command classes#993
dereuromark merged 1 commit into5.xfrom
normalize-exception-handling

Conversation

@dereuromark
Copy link
Copy Markdown
Member

Summary

Normalizes exception handling patterns across command classes for consistency.

Changes

MigrateCommand & RollbackCommand

  • Remove redundant catch (Exception $e) block since catch (Throwable $e) already covers all exceptions
  • Remove unused use Exception; import

SeedCommand

  • Change from catch (Exception $e) to catch (Throwable $e) for consistency
  • Use $io->err('<error>...</error>') instead of $io->error() to match other commands
  • Add $io->verbose($e->getTraceAsString()) for debugging consistency

Before/After

Before (MigrateCommand/RollbackCommand):

} catch (Exception $e) {
    $io->err('<error>' . $e->getMessage() . '</error>');
    $io->verbose($e->getTraceAsString());
    return self::CODE_ERROR;
} catch (Throwable $e) {
    $io->err('<error>' . $e->getMessage() . '</error>');
    $io->verbose($e->getTraceAsString());
    return self::CODE_ERROR;
}

After:

} catch (Throwable $e) {
    $io->err('<error>' . $e->getMessage() . '</error>');
    $io->verbose($e->getTraceAsString());
    return self::CODE_ERROR;
}

Test plan

  • phpcs passes
  • phpstan passes
  • Existing tests pass

- Remove redundant Exception catch when Throwable already covers it
- Use consistent error output formatting with <error> tags
- Add verbose trace output to SeedCommand for consistency
- Remove unused Exception imports
@dereuromark dereuromark merged commit 653da16 into 5.x Jan 11, 2026
14 checks passed
@dereuromark dereuromark deleted the normalize-exception-handling branch January 11, 2026 08:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant