errorCode = $errorCode; parent::__construct($message, $code, $previous); } /** * Get error code. */ public function getErrorCode(): string { return $this->errorCode; } /** * Render the exception as JSON response. */ public function render(): \Illuminate\Http\JsonResponse { return response()->json([ 'success' => false, 'message' => $this->getMessage(), 'error_code' => $this->errorCode, ], $this->getCode()); } /** * Create exception for rider not found. */ public static function notFound(int|string $identifier): self { return new self( "Rider '{$identifier}' not found", 'RIDER_NOT_FOUND', 404 ); } /** * Create exception for rider not verified. */ public static function notVerified(): self { return new self( 'Rider account is not verified', 'RIDER_NOT_VERIFIED', 403 ); } /** * Create exception for rider suspended. */ public static function suspended(): self { return new self( 'Rider account is suspended', 'RIDER_SUSPENDED', 403 ); } /** * Create exception for rider not available. */ public static function notAvailable(): self { return new self( 'Rider is not available to accept orders', 'RIDER_NOT_AVAILABLE', 400 ); } /** * Create exception for rider at max capacity. */ public static function atMaxCapacity(): self { return new self( 'Rider has reached maximum concurrent orders limit', 'RIDER_AT_MAX_CAPACITY', 400 ); } /** * Create exception for invalid location. */ public static function invalidLocation(): self { return new self( 'Invalid rider location data', 'INVALID_RIDER_LOCATION', 400 ); } /** * Create exception for rider offline. */ public static function offline(): self { return new self( 'Rider is currently offline', 'RIDER_OFFLINE', 400 ); } }