Repository navigation
Errors
Phil edited this page Oct 3, 2026
·
1 revision
When Learning Locker answers with a 4xx or 5xx, LaraLocker throws Ijeffro\Laralocker\Exceptions\LearningLockerException.
use Ijeffro\Laralocker\Exceptions\LearningLockerException;
try {
$store = LearningLocker::store($id)->get();
} catch (LearningLockerException $e) {
$e->status(); // 404
$e->response; // the Illuminate\Http\Client\Response
$e->getMessage(); // "Learning Locker answered GET v2/lrs/… with 404: …"
}| Status | Usually means |
|---|---|
| 401 | The key or secret is wrong, or the client is disabled. |
| 403 | The client lacks the scope for the call. Give it API All or xAPI All. |
| 404 | No document with that _id in the client's organisation. |
| 405 | Learning Locker doesn't allow this, for example creating statements over /api/v2/statement. |
| 400 | Learning Locker rejected the data, for example an invalid xAPI statement. |
The same exception is thrown before any request when the URL, key or secret is missing from the config.
Calling update() or delete() without an _id throws InvalidArgumentException. An incomplete xAPI statement does the same.
LaraLocker uses Laravel's HTTP client, so Http::fake() covers it and no Learning Locker is needed:
use Illuminate\Support\Facades\Http;
Http::fake([
'your-learning-locker.example.com/api/v2/lrs*' => Http::response([['_id' => '1', 'title' => 'Main']]),
'your-learning-locker.example.com/data/xAPI/statements' => Http::response(['3f1a1c5e-0000-4000-8000-000000000001']),
]);
// ... run the code under test ...
Http::assertSent(fn ($request) => $request->url() === 'https://your-learning-locker.example.com/data/xAPI/statements');