{"record":{"id":"3c10d4010991d024","repo":"flarum/framework","slug":"resourcenotfoundexception","errorCode":null,"errorMessage":"ResourceNotFoundException","messagePattern":"ResourceNotFoundException","errorType":"http","errorClass":"ResourceNotFoundException","httpStatus":404,"severity":"error","filePath":"framework/core/src/Api/JsonApi.php","lineNumber":95,"sourceCode":"\n    /**\n     * Get a collection by name or class.\n     *\n     * @throws ResourceNotFoundException if the collection has not been defined.\n     */\n    public function getCollection(string $type): Collection\n    {\n        if (isset($this->collections[$type])) {\n            return $this->collections[$type];\n        }\n\n        foreach ($this->collections as $instance) {\n            if ($instance instanceof $type) {\n                return $instance;\n            }\n        }\n\n        throw new ResourceNotFoundException($type);\n    }\n\n    /**\n     * Get a resource by type or class.\n     *\n     * @throws ResourceNotFoundException if the resource has not been defined.\n     */\n    public function getResource(string $type): Resource\n    {\n        if (isset($this->resources[$type])) {\n            return $this->resources[$type];\n        }\n\n        foreach ($this->resources as $instance) {\n            if ($instance instanceof $type) {\n                return $instance;\n            }\n        }","sourceCodeStart":77,"sourceCodeEnd":113,"githubUrl":"https://github.com/flarum/framework/blob/4b939f685389bfe8a380e9e28ddf305a1c66950c/framework/core/src/Api/JsonApi.php#L77-L113","documentation":"Thrown by JsonApi::getCollection when no registered collection matches the requested type, either by exact name key or by instance-of check against the class string. Means the API was asked for a resource type that has never been registered with this JsonApi instance (missing extension, typo in type, or collection not registered in the extension's extend.php).","triggerScenarios":"Thrown at framework/core/src/Api/JsonApi.php:95 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Register the collection via the JsonApi registerCollection (or the corresponding extender) so the type resolves","Correct the type/class string in the request or caller so it matches a registered collection","Confirm the extension that defines the resource is enabled"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"4b939f685389bfe8a380e9e28ddf305a1c66950c","analyzedAt":"2026-09-15T18:09:20.879Z","contentChangedAt":"2026-09-15T18:09:20.879Z","schemaVersion":2},"datasetVersion":"2026-09-16T09:17:16.951Z"}