- What is keboola/api-error-control used for?
- It is a lightweight PHP library for handling errors returned by Keboola APIs consistently. It provides standardized API exception types, maps API and HTTP failures to exceptions, and helps format predictable error responses. It is framework-agnostic, so it can be used in Laravel services, queue jobs, or standalone PHP clients.
- How do I install and configure keboola/api-error-control in Laravel?
- Install it with Composer using composer require keboola/api-error-control. The package is autoloaded through Composer, so you can reference its exception classes directly from your Laravel services and controllers. It is designed to be lightweight, and you generally do not need a Laravel service provider or configuration file unless your installed version documents one.
- Does keboola/api-error-control support Laravel 10 and Laravel 11?
- The package is framework-agnostic, so Laravel 10 and Laravel 11 compatibility mainly depends on your PHP version and Composer constraints rather than a Laravel-specific adapter. Check the package's composer.json for its PHP requirement before upgrading. In practice it can be used with any Laravel version that satisfies that PHP constraint.
- How do I convert Keboola API HTTP failures into exceptions?
- When your Keboola API client receives a non-success HTTP response, inspect the status code and response body and throw the matching exception type from the package. The library is intended to map API and HTTP failures to structured exceptions and consistent error payloads. Wrap the client call in a try/catch block so your application can log, report, and recover predictably.
- How do I return consistent JSON error responses from a Laravel API using this package?
- Catch the package's API exceptions in your application's exception handler, such as bootstrap/app.php withExceptions in newer Laravel versions. Map the exception status code and message to a JSON response with a stable payload shape. Keep internal details out of the response and log the original exception context separately.
- Can I use keboola/api-error-control without Laravel?
- Yes, the package is framework-agnostic and lightweight by design. You can use it in any PHP project that installs it through Composer, including standalone scripts, Symfony applications, and custom API clients. It does not require Laravel to provide its exception types or error response helpers.
- How do I test Keboola API error handling with this package in Laravel?
- Use Laravel's HTTP fake or a mock client to return representative Keboola API error responses, then assert that your code throws the expected package exception with the right status code and payload. Unit-test any response formatting or mapping helpers separately. Include tests for malformed or unexpected error bodies so production behavior stays predictable.
- What are the alternatives to keboola/api-error-control?
- Common alternatives include Laravel's built-in RequestException from the HTTP client, Guzzle exceptions, Symfony HTTP exceptions, or your own custom exception hierarchy. The package is most useful when you want Keboola-specific exception types and consistent error payloads without building them yourself. For generic HTTP error handling, Laravel's native exceptions may be sufficient.
- Is keboola/api-error-control actively maintained?
- The repository location is not specified in the package information, so verify maintenance status on Packagist and the vendor's source repository before adopting it. Check the release history, open issues, and PHP version constraints. Because it is a small library, stability and compatibility often matter more than frequent releases.
- What production concerns should I consider when using keboola/api-error-control?
- Do not return raw Keboola API error bodies to end users because they can contain internal identifiers or sensitive details. Log the original exception and payload with appropriate redaction, return a safe JSON message, and map status codes carefully so 4xx and 5xx responses are not confused. Also confirm that credentials used by your API client are not included in exception messages.