Skip to content

Conversation

@jimkring
Copy link
Contributor

@jimkring jimkring commented Aug 24, 2025

This PR implements significant error handling improvements for the reqwest-rs-labview library:

Core Changes:

  1. Enhanced Error Classification - Added 11 error type constants (ERROR_KIND_NONE through ERROR_KIND_UNKNOWN) for machine-readable error identification in LabVIEW
  2. Detailed Error Information - New error tracking fields:
    - error_kind: Type of error (timeout, connection, etc.)
    - error_url: URL associated with the error
    - error_source: Root cause from error chain
    - error_message: Detailed human-readable message
  3. New Error Analysis - Created analyze_reqwest_error() function in async_support.rs that classifies errors and extracts detailed information
  4. New LabVIEW VIs:
    - get_error_kind.vi - Returns error type constant
    - get_error_message.vi - Returns detailed error message
    - get_error_url.vi - Returns associated URL
    - get_error_source.vi - Returns root cause
    - get_has_error.vi - Checks for any error
    - raise_any_errors.vi - New error raising VI
    - reqwest_error_kind_enum.ctl - Error kind enumeration control
  5. Removed/Replaced VIs:
    - Removed get_has_transport_error.vi and get_transport_error.vi in favor of the new comprehensive error handling

The changes provide both machine-readable error classification for programmatic handling and human-readable detailed messages for debugging, making error handling in LabVIEW applications more robust and informative.

This enables raising very detailed error information, was well as allowing the user to check the type of error (like a timeout error) via the get_error_kind.vi method.

image

Fixes #38

provides both machine-readable error classification and human-readable detailed messages

  1. Error Kind Constants (in types.rs)

  Added 11 error type constants that map to LabVIEW enums:
  - ERROR_KIND_NONE through ERROR_KIND_UNKNOWN

  2. Enhanced Response Structure (in types.rs)

  Added three new fields to track error details:
  - error_kind: The type of error (timeout, connection, etc.)
  - error_url: The URL associated with the error
  - error_source: The root cause from the error chain

  3. Error Analysis Function (in async_support.rs)

  Created analyze_reqwest_error() that:
  - Classifies errors using reqwest's is_*() methods
  - Extracts the URL if available
  - Gets the root cause via source()
  - Builds a detailed error message with the full error chain

  4. New FFI Functions (in ffi/request.rs)

  - request_get_error_kind() - Returns the error type constant
  - request_get_error_message() - Returns the detailed error message
  - request_get_error_url() - Returns the URL if available
  - request_get_error_source() - Returns the root cause
  - request_response_has_error() - Checks if there's any error

  5. Exports Updated (in lib.rs)

  All new functions are exported for use by LabVIEW

  Now when you get a timeout error, you'll be able to:
  1. Call request_get_error_kind() and get ERROR_KIND_TIMEOUT (value 1)
  2. Call request_get_error_message() to get a detailed message including the root cause
  3. Call request_get_error_url() to see which URL failed
  4. Call request_get_error_source() to get just the underlying error cause
@jimkring jimkring merged commit 91a3b1c into main Aug 24, 2025
5 checks passed
@jimkring jimkring deleted the error-handling-improvements branch August 24, 2025 17:13
@jimkring jimkring mentioned this pull request Aug 25, 2025
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.

Timeout is not implemented in lv_src\HTTP Client Plugin\GET.vi

2 participants