Skip to content

Conversation

@mahmoud-ghalayini
Copy link
Collaborator

Public API Changes
Added 21 new error classes (all exported from rclnodejs):

Base:

  • RclNodeError - Base class with rich context (code, nodeName, entityType, timestamp, details, toJSON())

Validation Errors:

  • ValidationError
  • TypeValidationError (includes argumentName, providedValue, expectedType)
  • RangeValidationError (includes argumentName, providedValue, validationRule)
  • NameValidationError (includes invalidName, nameType)

Operation Errors:

  • OperationError
  • TimeoutError (includes timeoutMs)
  • AbortError (includes reason)
  • ServiceNotFoundError (includes serviceName)
  • NodeNotFoundError (includes nodeName)

Parameter Errors:

  • ParameterError
  • ParameterNotFoundError (includes parameterName, remoteNodeName)
  • ParameterTypeError (includes parameterName, expectedType, actualType)
  • ReadOnlyParameterError (includes parameterName)

Topic/Action Errors:

  • TopicError, PublisherError, SubscriptionError
  • ActionError, GoalRejectedError, ActionServerNotFoundError

Native Errors:

  • NativeError (wraps C++ errors with nativeMessage, operation)

Breaking (but backward compatible):

  • Existing methods now throw specific error types instead of generic TypeError/Error/RangeError
  • All new errors extend Error, so existing catch (error) blocks still work
  • Users can now catch specific error types for better error handling (e.g., catch (error) { if (error instanceof rclnodejs.TimeoutError) ... })

1319

@coveralls
Copy link

coveralls commented Nov 4, 2025

Coverage Status

coverage: 83.047% (+0.3%) from 82.711%
when pulling 3adc9f0 on mahmoud-ghalayini:feat-add-structured-error-handling-with-error-class-hierarchy-1319
into 3ad842c on RobotWebTools:develop.

@minggangw
Copy link
Member

@mahmoud-ghalayini Thanks for submitting such a BIG pr 😄 will start reviewing it asap.

@minggangw minggangw requested a review from Copilot November 6, 2025 01:38
Copy link

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 a comprehensive structured error handling system for rclnodejs, replacing generic JavaScript errors (TypeError, RangeError, Error) with specialized error classes organized in a clear hierarchy. The changes include 21 error classes extending from a base RclNodeError, complete TypeScript definitions, comprehensive tests, and example documentation.

Key changes:

  • New error class hierarchy with base RclNodeError and specialized subclasses (ValidationError, OperationError, ParameterError, TopicError, ActionError, NativeError)
  • Updated all error throwing sites across the codebase to use new error classes
  • Added TypeScript type definitions for all error classes
  • Comprehensive test suite with 100+ test cases
  • Example code and documentation demonstrating error handling patterns

Reviewed Changes

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

Show a summary per file
File Description
lib/errors.js Core implementation of 21 error classes with structured context
types/errors.d.ts TypeScript definitions for all error classes
test/test-errors.js Comprehensive test suite covering all error classes
index.js Exports all error classes to public API
lib/*.js Updated 15+ files to use new error classes
test/*.js Updated test assertions to expect new error types
example/error-handling/* Examples and documentation for error handling patterns

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

Copy link
Member

@minggangw minggangw left a comment

Choose a reason for hiding this comment

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

lgtm, please go ahead to merge it when comments addressed as the fix is straightforward, thanks!

@mahmoud-ghalayini mahmoud-ghalayini force-pushed the feat-add-structured-error-handling-with-error-class-hierarchy-1319 branch from 9cad456 to 9602c40 Compare November 7, 2025 09:33
@mahmoud-ghalayini
Copy link
Collaborator Author

Thanks for the comments, all are fixed. but can we review again just in case 😆 @minggangw

@minggangw minggangw requested a review from Copilot November 10, 2025 02:06
Copy link

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

Copilot reviewed 41 out of 43 changed files in this pull request and generated 3 comments.


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

Copy link
Member

@minggangw minggangw left a comment

Choose a reason for hiding this comment

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

I re-triggered the copilot and it found another 3 issues, please help to fix them. Also, I reviewed it manually, the rest seems good. We could split the PR into small ones in the future to facilitate the review work.

LGTM, thanks for refactoring the error hierarchy, I believe it helps the developers to identify where goes wrong easily and quickly!

@mahmoud-ghalayini mahmoud-ghalayini force-pushed the feat-add-structured-error-handling-with-error-class-hierarchy-1319 branch from 9602c40 to 3adc9f0 Compare November 10, 2025 12:45
@mahmoud-ghalayini mahmoud-ghalayini merged commit bceb9a6 into RobotWebTools:develop Nov 10, 2025
16 checks passed
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.

3 participants