Some checks are pending
Bidi Control Character Guard / bidi-control-guard (push) Waiting to run
Circular Dependency Check / Check for new circular dependencies (push) Waiting to run
Citus Migration Smoke / Combined migrations on single-node Citus (push) Waiting to run
E2E Fresh Install Tests / fresh-install-e2e (push) Waiting to run
ext-v2 guardrails / Run ext-v2 guard and ESLint (push) Waiting to run
Integration Tests / Check for relevant changes (push) Waiting to run
Integration Tests / ${{ (github.event_name == 'schedule' || github.event.inputs.suite == 'full') && 'Full integration suite' || 'Tier-1 integration subset' }} (push) Blocked by required conditions
Mobile checks / Mobile lint + typecheck (push) Waiting to run
Mobile checks / Mobile unit tests (push) Waiting to run
Mobile checks / Mobile dependency audit (report) (push) Waiting to run
Mobile checks / Mobile reproducibility checks (push) Waiting to run
Secrets guard (env backups) / Ensure no tracked env backup files (push) Waiting to run
Temporal Readiness / fast-readiness (push) Waiting to run
Temporal Readiness / docker-parity (push) Waiting to run
TypeScript Type Check / Nx affected typecheck (push) Waiting to run
Unit Tests / Skipped-test budget (push) Waiting to run
Unit Tests / Nx affected unit tests (push) Waiting to run
Unit Tests / Server unit coverage (informational) (push) Waiting to run
Validate Tenant Management Schema / Check for relevant changes (push) Waiting to run
Validate Tenant Management Schema / Validate Tenant Management Schema (push) Blocked by required conditions
EE Workflows Build Guard / ee-workflows-build-guard (push) Waiting to run
Excluded: .git, node_modules, secrets/, compose.env, assemblyscript tgz Source: /opt/alga-psa on psa.joliet.tech
2.2 KiB
2.2 KiB
Permission Error Handling
Overview
The application uses a consistent approach to handle permission-related errors with a distinct visual style to differentiate them from regular errors.
Error Handling Utility
The errorHandling.ts utility provides:
Client-side Functions
-
handleError(error, fallbackMessage?)- Automatically detects permission errors
- Shows permission errors with:
- ShieldAlert icon (from Lucide)
- Light red background (#FEF2F2)
- Dark red text (#991B1B)
- Red border (#FCA5A5)
- Longer duration (5 seconds)
- Shows regular errors with default toast styling
-
isPermissionError(error)- Checks if an error message contains "Permission denied"
- Returns boolean
-
useErrorHandler()- React hook that provides error handling utilities
Server-side Functions
throwPermissionError(action, additionalInfo?)- Throws consistent permission errors
- Format: "Permission denied: You don't have permission to [action]. [additionalInfo]"
Usage Examples
In Components
import { handleError } from 'server/src/lib/utils/errorHandling';
try {
await createTag({ ... });
} catch (error) {
handleError(error, 'Failed to add tag');
}
In Server Actions
import { throwPermissionError } from 'server/src/lib/utils/errorHandling';
if (!await hasPermission(user, 'tag', 'create')) {
throwPermissionError('create new tags', 'You can only select from existing tags');
}
Visual Examples
Permission Error
- Message: "Permission denied: You don't have permission to create new tags. You can only select from existing tags"
- Icon: ShieldAlert (Lucide icon in red)
- Background: Light red
- Duration: 5 seconds
- Style: Prominent border and coloring
Regular Error
- Message: "Failed to add tag"
- Icon: Default error icon
- Background: Default toast background
- Duration: Default (3 seconds)
- Style: Standard error toast
Benefits
- Consistency: All permission errors look the same across the app
- Clarity: Users immediately know when an action failed due to permissions
- Helpfulness: Permission errors often include additional context
- Maintainability: Single place to update permission error styling