8000 fix/3061-replace-exit-statements by Aditya30ag · Pull Request #3071 · fossology/fossology · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

fix/3061-replace-exit-statements #3071

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Conversation

Aditya30ag
Copy link

Replace exit statements with proper error handling

Description

This PR addresses issue #3061 by replacing abrupt exit statements with proper exception handling in two files:

  1. src/lib/php/Report/LicenseMainGetter.php
  2. src/spdx/agent/spdx.php

The changes ensure that when a license is not found in the database, the process doesn't terminate abruptly but instead throws an exception that can be properly handled by the calling code.

Changes Made

  1. In LicenseMainGetter.php:

    • Replaced exit with throw new \Exception() when a license is not found
    • Maintained error logging while adding proper exception handling
    • Error message clearly indicates which license ID was not found
  2. In spdx.php:

    • Replaced exit with throw new \Exception() when a main license is not found
    • Preserved error logging functionality
    • Added descriptive error message for better debugging

Benefits

  • Prevents abrupt process termination
  • Provides proper error feedback to requestors
  • Maintains system stability
  • Allows for graceful error handling by calling code
  • Preserves error logging for debugging purposes

Testing

The calling code should be updated to handle these exceptions appropriately using try-catch blocks. For example:

try {
    $statements = $this->getStatements($uploadId, $uploadTreeTableName, $groupId);
} catch (\Exception $e) {
    error_log($e->getMessage());
    // Handle error appropriately
}

Related Issues

Fixes #3061

@Aditya30ag
Copy link
Author

please review my changes

@shaheemazmalmmd
Copy link
Member

Fix already available : #3067 thanks for contribution.

@Aditya30ag Aditya30ag deleted the fix/3061-replace-exit-statements branch June 25, 2025 15:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Assignees
No one assigned
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Process should not exit
2 participants
0