Skip to content

Comments

Introduce On error handler#1537

Merged
niveathika merged 7 commits intomasterfrom
on-error
Feb 9, 2026
Merged

Introduce On error handler#1537
niveathika merged 7 commits intomasterfrom
on-error

Conversation

@niveathika
Copy link
Contributor

@niveathika niveathika commented Feb 5, 2026

Purpose

Fixes ballerina-platform/ballerina-library#8605

Examples

Checklist

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

@niveathika niveathika requested a review from Copilot February 5, 2026 05:41
@niveathika niveathika added the Skip GraalVM Check This will skip the GraalVM compatibility check label Feb 5, 2026
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 PR introduces an onError handler for FTP services to handle content binding failures. When file content cannot be converted to the expected type (JSON, XML, CSV, or record types), a new ContentBindingError is raised. Services can define an optional onError remote function to handle these errors, enabling custom error handling such as moving failed files or logging.

Changes:

  • Added ContentBindingError type with detail record containing file path and raw content bytes
  • Introduced onError remote function support with validation (accepts ftp:Error or error as first parameter, optional Caller as second)
  • Updated content converters to return ContentBindingError instead of generic errors, with file path context
  • Added comprehensive compiler plugin validation and tests for the new error handler

Reviewed changes

Copilot reviewed 26 out of 26 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
ballerina/error.bal Defines ContentBindingError type and detail record
ballerina/tests/listener_on_error_test.bal Tests onError handler with various scenarios including minimal/full parameters and caller operations
ballerina/tests/client_endpoint_test.bal Tests ContentBindingError is returned from client operations on parsing failures
native/src/main/java/io/ballerina/stdlib/ftp/util/FtpUtil.java Adds getOnErrorMethod() and createContentBindingError() helper methods
native/src/main/java/io/ballerina/stdlib/ftp/util/FtpContentConverter.java Updates converters to return ContentBindingError with file path and content
native/src/main/java/io/ballerina/stdlib/ftp/util/FtpConstants.java Adds ON_ERROR_REMOTE_FUNCTION and CONTENT_BINDING_ERROR constants
native/src/main/java/io/ballerina/stdlib/ftp/server/FtpContentCallbackHandler.java Implements onError routing when content binding fails
native/src/main/java/io/ballerina/stdlib/ftp/server/FormatMethodsHolder.java Tracks onError method availability
native/src/main/java/io/ballerina/stdlib/ftp/client/FtpClient.java Passes file path to content converters for error context
compiler-plugin/src/main/java/io/ballerina/stdlib/ftp/plugin/PluginConstants.java Adds error codes and constants for onError validation
compiler-plugin/src/main/java/io/ballerina/stdlib/ftp/plugin/FtpServiceValidator.java Integrates onError validation into service validation
compiler-plugin/src/main/java/io/ballerina/stdlib/ftp/plugin/FtpOnErrorValidator.java Validates onError function signature and parameters
compiler-plugin-tests/* Adds test cases for valid and invalid onError handlers
spotbugs-exclude.xml Excludes EI_EXPOSE_REP2 for FtpOnErrorValidator

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

@niveathika
Copy link
Contributor Author

@copilot open a new pull request to apply changes based on the comments in this thread

Copy link
Contributor

Copilot AI commented Feb 5, 2026

@niveathika I've opened a new pull request, #1538, to work on those changes. Once the pull request is ready, I'll request review from you.

@codecov
Copy link

codecov bot commented Feb 5, 2026

Codecov Report

❌ Patch coverage is 74.21875% with 33 lines in your changes missing coverage. Please review.
✅ Project coverage is 78.47%. Comparing base (87f197d) to head (9c1dbfe).
⚠️ Report is 8 commits behind head on master.

Files with missing lines Patch % Lines
...llerina/stdlib/ftp/plugin/FtpOnErrorValidator.java 67.24% 12 Missing and 7 partials ⚠️
...ain/java/io/ballerina/stdlib/ftp/util/FtpUtil.java 68.18% 3 Missing and 4 partials ⚠️
...a/stdlib/ftp/server/FtpContentCallbackHandler.java 80.00% 2 Missing and 2 partials ⚠️
...ballerina/stdlib/ftp/util/FtpContentConverter.java 81.81% 2 Missing ⚠️
...llerina/stdlib/ftp/server/FormatMethodsHolder.java 66.66% 0 Missing and 1 partial ⚠️

❌ Your project status has failed because the head coverage (78.47%) is below the target coverage (80.00%). You can increase the head coverage or adjust the target coverage.

Additional details and impacted files
@@             Coverage Diff              @@
##             master    #1537      +/-   ##
============================================
+ Coverage     77.89%   78.47%   +0.58%     
- Complexity      709      938     +229     
============================================
  Files            55       71      +16     
  Lines          3537     4237     +700     
  Branches        591      735     +144     
============================================
+ Hits           2755     3325     +570     
- Misses          547      604      +57     
- Partials        235      308      +73     

☔ 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.

@niveathika niveathika requested a review from TharmiganK February 5, 2026 09:47
@sonarqubecloud
Copy link

sonarqubecloud bot commented Feb 8, 2026

Copy link
Contributor

@TharmiganK TharmiganK left a comment

Choose a reason for hiding this comment

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

LGTM

@niveathika niveathika merged commit 0ea7960 into master Feb 9, 2026
6 of 10 checks passed
@niveathika niveathika deleted the on-error branch February 12, 2026 12:04
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.

Introduce onError resource for FTP Listener

3 participants