bitrix-result-and-errors

Standardize Bitrix API results, errors, and error collections across services.

33|3|Updated Jun 5, 2025
One-click install
npx skills add https://github.com/bxmaximum/bitrix_ai_challenge --skill bitrix-result-and-errors
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: bitrix-result-and-errors
Source: https://github.com/bxmaximum/bitrix_ai_challenge/tree/main/.agents/skills/bitrix-result-and-errors
Command: npx skills add https://github.com/bxmaximum/bitrix_ai_challenge --skill bitrix-result-and-errors

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

This Skill standardizes the handling of Bitrix results, errors, and error collections across services and controllers, enabling predictable API responses without relying on exceptions for expected failure cases.

Core Features & Use Cases

  • Typed Result patterns (AddResult, UpdateResult, DeleteResult) provide stable contracts and typed data access.
  • Centralized error handling using \Bitrix\Main\Error and \Bitrix\Main\ErrorCollection ensures consistent error codes and client-facing messages.
  • Clear controller integration: convert Result errors into client responses, improving reliability and debuggability in API services.

Quick Start

Create a simple Result-based service method that validates input, returns a Result with errors on failure, and returns data on success.

Frequently Asked Questions about bitrix-result-and-errors

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I standardize Bitrix API result and error handling across controllers?

Standardize Bitrix API result and error handling by using typed Result contracts like AddResult, UpdateResult, and DeleteResult, and propagating ErrorCollection through controllers for predictable API responses.

What is the best way to return errors from a Bitrix service method without exceptions?

Return errors without exceptions by utilizing Bitrix\Main\Result objects and the addError method with ErrorCollection, allowing services to communicate validation failures and expected errors safely back to controllers.

How do Bitrix typed Results like AddResult and UpdateResult improve API design?

Bitrix typed Results like AddResult and UpdateResult improve API design by providing stable contracts and typed data access, ensuring consistent success and failure propagation across module services.

Can I use Bitrix ErrorCollection to centralize error handling in custom modules?

Yes, you can use Bitrix\Main\Error and ErrorCollection to centralize error handling in custom modules, ensuring consistent error codes and client-facing messages by collecting and propagating errors through Result objects.

When should I use Bitrix Result-based contracts instead of throwing exceptions?

Use Bitrix Result-based contracts instead of throwing exceptions for expected failure cases like validation errors, enabling predictable API responses and improving reliability and debuggability in controller layers.

Does this Bitrix error consolidation approach require specific Result types?

Yes, this Bitrix error consolidation approach requires typed Results such as AddResult, UpdateResult, and DeleteResult, along with code-based Error and ErrorCollection patterns using addError for proper service contracts.