Skip to content

Add error handling, observability, and monitoring to AsyncApex framework#3

Draft
Copilot wants to merge 9 commits into
feat/apex-cursors-custom-batchfrom
copilot/improve-framework
Draft

Add error handling, observability, and monitoring to AsyncApex framework#3
Copilot wants to merge 9 commits into
feat/apex-cursors-custom-batchfrom
copilot/improve-framework

Conversation

Copy link
Copy Markdown

Copilot AI commented Feb 17, 2026

The AsyncApex framework lacked production-ready error handling, observability, and job monitoring capabilities. This adds typed exceptions, structured logging, and runtime job management utilities.

Error Handling

AsyncException - Typed exception with categories:

throw new AsyncException(AsyncException.ErrorType.CACHE_ERROR, 'Failed to cache job', jobId);

Input Validation - All public methods validate parameters:

// EnqueueJobs now validates inputs
EnqueueJobs.Batch(null); // throws AsyncException
EnqueueJobs.Batch(batch, 0); // throws AsyncException (batch size 1-2000)

Automatic Cleanup - Cache entries removed on errors to prevent orphaned data.

Observability

AsyncLogger - Structured logging with context:

AsyncLogger.logError(jobId, 'Batch', 'Processing failed', ex);
// [AsyncFramework] [ERROR] [JobId: async123] [Context: Batch] Processing failed

AsyncJobUtils - Runtime job monitoring:

// Check job status
Boolean exists = AsyncJobUtils.jobExists(jobId);
Map<String, Object> info = AsyncJobUtils.getJobInfo(jobId);

// Cancel pending job
AsyncJobUtils.cancelJob(jobId);

// List active jobs
List<String> activeJobs = AsyncJobUtils.getActiveJobIds();

Enhanced Classes

  • EnqueueJobs - Validation, error handling, logging
  • AsyncJobTriggerHandler - Try-catch blocks, cleanup on errors
  • CursorWrapper - Input validation, error context
  • Async - Complete JavaDoc for all interfaces
  • Sample classes - Edge case validation

Testing

8 new test classes covering error scenarios, edge cases, and all new utilities.

Documentation

Enhanced README with:

  • Error handling patterns
  • Performance optimization guidelines
  • Monitoring and troubleshooting
  • Code examples throughout
Original prompt

Improve this framework


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Copilot AI and others added 8 commits February 17, 2026 01:37
Co-authored-by: smn2gnt <5411338+smn2gnt@users.noreply.github.com>
Co-authored-by: smn2gnt <5411338+smn2gnt@users.noreply.github.com>
Co-authored-by: smn2gnt <5411338+smn2gnt@users.noreply.github.com>
…tent

Co-authored-by: smn2gnt <5411338+smn2gnt@users.noreply.github.com>
Co-authored-by: smn2gnt <5411338+smn2gnt@users.noreply.github.com>
Co-authored-by: smn2gnt <5411338+smn2gnt@users.noreply.github.com>
Co-authored-by: smn2gnt <5411338+smn2gnt@users.noreply.github.com>
Copilot AI changed the title [WIP] Improve overall framework functionality Add error handling, observability, and monitoring to AsyncApex framework Feb 17, 2026
Copilot AI requested a review from smn2gnt February 17, 2026 01:48
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