⚠ This page is served via a proxy. Original site: https://github.com
This service does not collect credentials or authentication data.
Skip to content

Conversation

@mattpodwysocki
Copy link
Contributor

Summary

Improves error handling across all Mapbox API tools by extracting the message field from JSON error responses.

Changes

  • Added getErrorMessage() helper method to MapboxApiBasedTool base class that extracts the message field from JSON error responses when available, falling back to status text otherwise
  • Updated all 10 API-based tools to use this helper:
    • DirectionsTool
    • SearchAndGeocodeTool
    • OptimizationTool
    • MapMatchingTool
    • MatrixTool
    • ReverseGeocodeTool
    • CategorySearchTool
    • StaticMapImageTool
    • IsochroneTool
    • CategoryListTool

Benefits

  • More informative error messages (e.g., "Not Authorized - Invalid Token" instead of "Unauthorized")
  • Consistent error handling across all tools
  • Centralized error parsing logic
  • Simplified code (reduced from 20+ lines to 5 lines in some tools)

Testing

  • All 580 tests passing
  • Updated test expectations to match new error message format

Related

@mattpodwysocki mattpodwysocki requested a review from a team as a code owner January 16, 2026 17:36
Add getErrorMessage() helper method to MapboxApiBasedTool base class
that extracts the 'message' field from JSON error responses when
available, falling back to status text otherwise.

Updated all 10 API-based tools to use this helper:
- DirectionsTool
- SearchAndGeocodeTool
- OptimizationTool
- MapMatchingTool
- MatrixTool
- ReverseGeocodeTool
- CategorySearchTool
- StaticMapImageTool
- IsochroneTool
- CategoryListTool

Benefits:
- More informative error messages (e.g., "Not Authorized - Invalid Token" vs "Unauthorized")
- Consistent error handling across all tools
- Centralized error parsing logic
- Simplified code (reduced from 20+ lines to 5 lines in some tools)

Co-Authored-By: Claude Sonnet 4.5 <[email protected]>
@mattpodwysocki mattpodwysocki requested a review from ctufts January 16, 2026 20:16
@mattpodwysocki mattpodwysocki merged commit c85ea6b into main Jan 16, 2026
5 checks passed
@mattpodwysocki mattpodwysocki deleted the improve-error-messages branch January 16, 2026 21:13
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.

2 participants