Add distinct error types#1530
Conversation
bda64fa to
29a973c
Compare
29a973c to
e6fa8e1
Compare
Codecov Report❌ Patch coverage is 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. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
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, andServiceUnavailableError - Adds
ErrorTypeProviderinterface and updates exception classes to implement it for automatic error type determination - Implements
FtpErrorCodeAnalyzerutility 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.
native/src/main/java/io/ballerina/stdlib/ftp/server/FtpListenerHelper.java
Outdated
Show resolved
Hide resolved
native/src/main/java/io/ballerina/stdlib/ftp/util/FtpErrorCodeAnalyzer.java
Show resolved
Hide resolved
|



Purpose
Fixes ballerina-platform/ballerina-library#8597
Examples
Checklist