Skip to content

Refactor error messages to common classes #799

Merged
cleemullins merged 8 commits intomainfrom
users/cleemullins/updateAKALinkTarget
Dec 2, 2025
Merged

Refactor error messages to common classes #799
cleemullins merged 8 commits intomainfrom
users/cleemullins/updateAKALinkTarget

Conversation

@cleemullins
Copy link
Copy Markdown
Collaborator

@cleemullins cleemullins commented Dec 1, 2025

This pull request introduces a structured error handling approach to the agents-activity and agents-hosting-dialogs packages by centralizing error definitions and replacing direct throw new Error statements with a standardized exception helper. This improves error consistency, makes error codes and help links available throughout the codebase, and prepares the system for better diagnostics and localization.

The most important changes are:

Centralized Error Definitions and Exports

  • Added a new errorHelper.ts file in agents-activity defining an Errors object with error codes, descriptions, and help links for all major error scenarios in the Activity system. This object is now exported as ActivityErrors for external use. [1] [2]

Refactoring Error Handling in Activity System

  • Updated the Activity class and related logic to use ExceptionHelper.generateException with entries from the new Errors object, replacing all direct throw new Error calls for invalid activity types, channel IDs, and required properties. [1] [2] [3] [4] [5]

Refactoring Error Handling in Dialog System

  • Updated multiple files in agents-hosting-dialogs (agentStateSet.ts, dialog.ts, dialogContextError.ts, dialogHelper.ts, dialogManager.ts, dialogSet.ts) to use the new error handling pattern, replacing direct error throws with ExceptionHelper.generateException and corresponding Errors entries for various validation and configuration errors. [1] [2] [3] [4] [5] [6] [7] [8] [9] [10] [11] [12] [13] [14]

Test Adjustments

  • Updated tests in exceptionHelper.test.ts to reflect the new help link format in error definitions.

This refactor makes error handling more robust, maintainable, and user-friendly by providing consistent error codes and documentation links across the codebase.Change all error definitions to point to the JavaScript version of the help links, ensuring consistency across the error handling implementation.

There are many JS Errors that need to be documented - enough that putting them into their own documentation file seems the most straigforward answer.

Copilot AI review requested due to automatic review settings December 1, 2025 17:13
Copy link
Copy Markdown
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 updates error definition help links from the generic M365AgentsErrorCodes to the JavaScript-specific M365AgentsErrorCodesJS to ensure consistency and proper documentation routing for JavaScript error codes.

  • Updates all error definition help links to use the JavaScript-specific documentation URL
  • Modifies both source error definitions and corresponding test assertions
  • Ensures consistency across the agents-hosting-storage-cosmos and agents-activity packages

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.

File Description
packages/agents-hosting-storage-cosmos/src/errorHelper.ts Updated all 20 error definitions to use M365AgentsErrorCodesJS help link
packages/agents-hosting-storage-cosmos/test/errorHelper.test.ts Updated test assertions to verify correct JavaScript-specific help links
packages/agents-activity/test/exceptionHelper.test.ts Updated test case to use JavaScript-specific help link for token replacement validation

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

Comment thread packages/agents-hosting-storage-cosmos/test/errorHelper.test.ts
@cleemullins cleemullins requested a review from benbrown December 1, 2025 21:29
@cleemullins cleemullins enabled auto-merge (squash) December 1, 2025 21:29
…tions

- Added errorHelper.ts to define a comprehensive set of error codes and descriptions for various scenarios.
- Updated activityHandler.ts, cloudAdapter.ts, and connectorClient.ts to utilize the new error definitions for improved error handling.
- Refactored error throwing to use ExceptionHelper for consistency across the codebase.
- Created unit tests for errorHelper to ensure correctness and uniqueness of error codes and messages.
Copy link
Copy Markdown
Contributor

Copilot AI commented Dec 2, 2025

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

@cleemullins cleemullins changed the title Update help links to use JS version for error definitions Refactor error messages to common classes Dec 2, 2025
Copy link
Copy Markdown
Contributor

@benbrown benbrown left a comment

Choose a reason for hiding this comment

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

The actual text of the aka.ms link probably should be assumed to be the default when not specified.

@cleemullins cleemullins merged commit a68644f into main Dec 2, 2025
7 checks passed
@cleemullins cleemullins deleted the users/cleemullins/updateAKALinkTarget branch December 2, 2025 22:04
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.

4 participants