Skip to content

Comments

Add distinct error types#1530

Merged
niveathika merged 19 commits intoballerina-platform:masterfrom
niveathika:error-structure
Feb 2, 2026
Merged

Add distinct error types#1530
niveathika merged 19 commits intoballerina-platform:masterfrom
niveathika:error-structure

Conversation

@niveathika
Copy link
Contributor

@niveathika niveathika commented Jan 29, 2026

Purpose

Fixes ballerina-platform/ballerina-library#8597

Examples

Checklist

  • Linked to an issue
  • Updated the changelog
  • Added tests
  • Updated the spec
  • Checked native-image compatibility

@niveathika niveathika added the Skip GraalVM Check This will skip the GraalVM compatibility check label Jan 29, 2026
@codecov
Copy link

codecov bot commented Jan 29, 2026

Codecov Report

❌ Patch coverage is 52.31788% with 72 lines in your changes missing coverage. Please review.
✅ Project coverage is 80.98%. Comparing base (2ab4ca2) to head (49223c7).
⚠️ Report is 20 commits behind head on master.

Files with missing lines Patch % Lines
...allerina/stdlib/ftp/util/FtpErrorCodeAnalyzer.java 37.28% 29 Missing and 8 partials ⚠️
.../ftp/exception/FtpServiceUnavailableException.java 0.00% 14 Missing ⚠️
...connector/contractimpl/VfsClientConnectorImpl.java 72.22% 2 Missing and 3 partials ⚠️
...ain/java/io/ballerina/stdlib/ftp/util/FtpUtil.java 79.16% 4 Missing and 1 partial ⚠️
...tdlib/ftp/exception/FtpInvalidConfigException.java 40.00% 3 Missing ⚠️
...java/io/ballerina/stdlib/ftp/client/FtpClient.java 50.00% 2 Missing ⚠️
...a/stdlib/ftp/exception/FtpConnectionException.java 60.00% 2 Missing ⚠️
...b/ftp/exception/FtpFileAlreadyExistsException.java 60.00% 2 Missing ⚠️
...stdlib/ftp/exception/FtpFileNotFoundException.java 60.00% 2 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff              @@
##             master    #1530      +/-   ##
============================================
- Coverage     81.70%   80.98%   -0.73%     
- Complexity      588      817     +229     
============================================
  Files            40       61      +21     
  Lines          2892     3607     +715     
  Branches        468      610     +142     
============================================
+ Hits           2363     2921     +558     
- Misses          337      427      +90     
- Partials        192      259      +67     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Nuvindu
Nuvindu previously approved these changes Feb 2, 2026
Copy link
Contributor

@Nuvindu Nuvindu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This pull request adds distinct error types to the FTP module for more granular error handling and better developer experience. The PR implements a hierarchy of error types that extend the base Error type, allowing developers to handle specific error scenarios differently.

Changes:

  • Introduces five new distinct error types: ConnectionError, FileNotFoundError, FileAlreadyExistsError, InvalidConfigurationError, and ServiceUnavailableError
  • Adds ErrorTypeProvider interface and updates exception classes to implement it for automatic error type determination
  • Implements FtpErrorCodeAnalyzer utility for analyzing FTP response codes in error messages and recommending appropriate error types
  • Updates client operations to throw specific exception types (e.g., FtpFileNotFoundException, FtpConnectionException) instead of generic exceptions
  • Adds regex pattern validation for listener configuration fields

Reviewed changes

Copilot reviewed 21 out of 21 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
ballerina/error.bal Defines five new distinct error types extending the base Error type
ballerina/tests/error_types_test.bal Adds comprehensive tests for all new error types
ballerina/tests/client_endpoint_test.bal Updates tests to expect specific error types instead of generic Error
ballerina/tests/client_endpoint_negative_test.bal Updates negative tests to validate specific error types and adds configuration validation tests
ballerina/tests/secure_listener_endpoint_with_caller_test.bal Updates expected error message (spelling fix from "exists" to "exist")
ballerina/tests/advanced_file_selection_test.bal Minor adjustment to polling interval
docs/spec/spec.md Documents the new error type hierarchy with examples
changelog.md Adds entry for distinct error types feature
native/.../FtpUtil.java Adds error type enum values, error type determination logic, and regex validation
native/.../FtpErrorCodeAnalyzer.java New utility class for analyzing FTP error codes and recommending error types
native/.../VfsClientConnectorImpl.java Updates to throw specific exception types based on error conditions
native/.../FtpListenerHelper.java Adds regex validation for configuration patterns and handles InvalidConfigurationError
native/.../FtpClient.java Uses getErrorTypeForException to determine appropriate error types
native/.../FtpClientListener.java Uses getErrorTypeForException for error handling
native/.../exception/*.java New exception classes implementing ErrorTypeProvider interface
ballerina/Dependencies.toml Deleted file (likely auto-generated)

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@sonarqubecloud
Copy link

sonarqubecloud bot commented Feb 2, 2026

@niveathika niveathika merged commit 8dd576f into ballerina-platform:master Feb 2, 2026
7 of 8 checks passed
@niveathika niveathika deleted the error-structure branch February 16, 2026 08:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Skip GraalVM Check This will skip the GraalVM compatibility check

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add distinct error types to the FTP module

4 participants