Skip to content
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

Expose error code in SendError #368

Merged
merged 14 commits into from
Nov 14, 2024

Commits on Nov 13, 2024

  1. Add enhanced status code and error code to SendError

    Enhance error handling by adding error code and enhanced status code to the SendError struct. This allows for better troubleshooting and debugging by providing more detailed SMTP server responses.
    wneessen committed Nov 13, 2024
    Configuration menu
    Copy the full SHA
    6809084 View commit details
    Browse the repository at this point in the history
  2. Change test server port base for SMTP client tests

    Updated the TestServerPortBase from 12025 to 30025 to avoid port conflicts with other services running on the common 12025 port. This adjustment aims to ensure that the tests run reliably in diverse environments.
    wneessen committed Nov 13, 2024
    Configuration menu
    Copy the full SHA
    b9d9449 View commit details
    Browse the repository at this point in the history
  3. Add ErrorCode method to SendError

    Implemented ErrorCode method to retrieve the error code from the server response in SendError. This method distinguishes between server-generated errors and client-generated errors, returning 0 for errors generated by the client.
    wneessen committed Nov 13, 2024
    Configuration menu
    Copy the full SHA
    ad265ca View commit details
    Browse the repository at this point in the history
  4. Add tests for SendError's enhanced status and error codes

    Implemented new unit tests for SendError to validate the enhanced status code and error codes in various scenarios, including nil SendError cases, errors with no enhanced status code, and errors with both permanent and temporary error codes. This ensures the correctness of the error handling behavior across different conditions.
    wneessen committed Nov 13, 2024
    Configuration menu
    Copy the full SHA
    615155b View commit details
    Browse the repository at this point in the history
  5. Add tests for getErrorCode function

    Introduce a suite of unit tests for the getErrorCode function to validate its behavior with various error types, including go-mail errors, permanent and temporary errors, wrapper errors, non-4xx/5xx errors, and non-3-digit codes.
    wneessen committed Nov 13, 2024
    Configuration menu
    Copy the full SHA
    e8fb977 View commit details
    Browse the repository at this point in the history
  6. Refactor error handling by renaming functions.

    Renamed `getErrorCode` to `errorCode` and `getEnhancedStatusCode` to `enhancedStatusCode` for consistency. Updated all references in `client.go` and `senderror.go` accordingly, improving readability and maintaining uniformity across the codebase.
    wneessen committed Nov 13, 2024
    Configuration menu
    Copy the full SHA
    6268aca View commit details
    Browse the repository at this point in the history
  7. Refactor error code functions and add enhanced status code tests

    Renamed `getErrorCode` function to `errorCode` for consistency. Added new tests for the `enhancedStatusCode` function to validate its behavior with various error scenarios.
    wneessen committed Nov 13, 2024
    Configuration menu
    Copy the full SHA
    f367db0 View commit details
    Browse the repository at this point in the history
  8. Enhance error handling with ENHANCEDSTATUSCODES check

    Added a check for the ENHANCEDSTATUSCODES extension and included error code and enhanced status code information in SendError. This helps in providing more detailed error reporting and troubleshooting.
    wneessen committed Nov 13, 2024
    Configuration menu
    Copy the full SHA
    719e5b2 View commit details
    Browse the repository at this point in the history
  9. Update error handling to include error code and status

    Previously, only the isTemp flag was considered when aggregating errors. Now, the error code and enhanced status code from the last error are also included. This ensures more comprehensive error reporting and handling.
    wneessen committed Nov 13, 2024
    Configuration menu
    Copy the full SHA
    a5ac7c3 View commit details
    Browse the repository at this point in the history

Commits on Nov 14, 2024

  1. Enhance error handling in Client's Send method

    Added support for Enhanced Status Codes (ESC) when checking the SMTP client's extensions. The SendError struct now includes the error code and enhanced status code for improved diagnostics.
    wneessen committed Nov 14, 2024
    Configuration menu
    Copy the full SHA
    c8d7cf8 View commit details
    Browse the repository at this point in the history
  2. Refactor SendError initialization for better readability

    Structured the initialization of SendError on connection errors to improve code readability and maintainability. This change affects the error handling in both client_120.go and client_119.go by spreading the error details across multiple lines.
    wneessen committed Nov 14, 2024
    Configuration menu
    Copy the full SHA
    bd655b7 View commit details
    Browse the repository at this point in the history
  3. Allow configuration of test server port via environment variable

    Moved TestServerPortBase initialization to use an environment variable `TEST_BASEPORT` if provided. This adjustment helps in specifying custom base ports for running tests, ensuring better flexibility in different testing environments.
    wneessen committed Nov 14, 2024
    Configuration menu
    Copy the full SHA
    ca3f505 View commit details
    Browse the repository at this point in the history
  4. Add TEST_BASEPORT environment variable to CI workflow

    In the CI configuration file, the TEST_BASEPORT environment variable was added to various job scopes. This ensures consistency and allows the test base port to be set properly across different OS versions and Go versions.
    wneessen committed Nov 14, 2024
    Configuration menu
    Copy the full SHA
    a70dde5 View commit details
    Browse the repository at this point in the history
  5. Update SMTP test port variable and CI configuration

    Changed the SMTP test server base port and updated the corresponding environment variable name to `TEST_BASEPORT_SMTP`. This ensures consistency across the test setup and CI workflow configuration.
    wneessen committed Nov 14, 2024
    Configuration menu
    Copy the full SHA
    2bde340 View commit details
    Browse the repository at this point in the history