Skip to content

Chore: Add debug logging for silent exception in RelationFinder.php#128

Open
zigzagdev wants to merge 3 commits into
beyondcode:mainfrom
zigzagdev:fix/add-condition-error-message
Open

Chore: Add debug logging for silent exception in RelationFinder.php#128
zigzagdev wants to merge 3 commits into
beyondcode:mainfrom
zigzagdev:fix/add-condition-error-message

Conversation

@zigzagdev

@zigzagdev zigzagdev commented May 14, 2026

Copy link
Copy Markdown

Summary

What I have done

  • Add opt-in debug logging to the catch (\Throwable $e) block in RelationFinder::getRelationshipFromMethodAndModel().
  • Logging is disabled by default and can be enabled by setting 'debug_relations' => true in config/erd-generator.php.
  • Add test to verify debug logging behavior when a method throws an exception.

Motivation

As reported in Issue #61, users have encountered silent failures inside the catch block of getRelationshipFromMethodAndModel, making it difficult to diagnose why relations are not detected.
This PR surfaces those errors in an opt-in manner, without polluting logs in production environments.

Changed

  • src/RelationFinder.php: Wrapped Log::debug() with a config('erd-generator.debug_relations', false) guard
  • config/erd-generator.php: Added commented-out debug_relations option with description
  • tests/Fixtures/ModelWithThrowingMethod.php: Test model that throws an exception
  • tests/GetModelRelationsTest.php: Test verifying the debug log output

Test Results

Screen Shot 2026-05-14 10 02 29

@zigzagdev zigzagdev closed this May 29, 2026
@zigzagdev zigzagdev reopened this May 29, 2026
@zigzagdev zigzagdev marked this pull request as draft May 29, 2026 00:57
@zigzagdev zigzagdev force-pushed the fix/add-condition-error-message branch from 812cfcd to 2949a6a Compare May 29, 2026 01:30
@zigzagdev zigzagdev marked this pull request as ready for review May 29, 2026 01:31
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