{"record":{"id":"ab266c1cc2fd7e9d","repo":"FyroxEngine/Fyrox","slug":"err-to-string","errorCode":null,"errorMessage":"err.to_string()","messagePattern":"err\\.to_string\\(\\)","errorType":"console","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"fyrox-impl/src/scene/tilemap/autotile.rs","lineNumber":381,"sourceCode":"        else {\n            return Ok(PatternBits::default());\n        };\n        self.property_id\n            .get_from_tile_set(self.tile_set, element.handle)\n            .map(|v| v.into())\n    }\n}\n\nimpl PatternSource for TileSetPatternSource<'_, '_, '_> {\n    type Position = Vector2<i32>;\n    type Terrain = TileTerrainId;\n    type Pattern = PatternBits;\n\n    fn get_terrain(&self, position: &Vector2<i32>) -> Option<TileTerrainId> {\n        match self.pattern_at(position) {\n            Ok(pattern) => Some(pattern.center()),\n            Err(err) => {\n                Log::err(err.to_string());\n                None\n            }\n        }\n    }\n    /// The constraint for the cell at the given position.\n    fn get(&self, position: &Vector2<i32>) -> TileConstraint<TileTerrainId, PatternBits> {\n        match self.pattern_at(position) {\n            Ok(pattern) => TileConstraint::Pattern(pattern),\n            Err(err) => {\n                Log::err(err.to_string());\n                TileConstraint::None\n            }\n        }\n    }\n}\n\n/// Wave function collapse propagator for the tiles of a [`TileSet`] that uses\n/// the nine-slice values of one of the tile set's properties as the wave function's","sourceCodeStart":363,"sourceCodeEnd":399,"githubUrl":"https://github.com/FyroxEngine/Fyrox/blob/76c91aad8eca488ce527b1af707be8b3b24ad72d/fyrox-impl/src/scene/tilemap/autotile.rs#L363-L399","documentation":"In TileMapCollidersSource::get_terrain, resolving the tile pattern at a position failed; the error is logged verbatim (err.to_string()) and None is returned for the terrain id. It indicates a position lookup failure in the autotiling pattern grid (e.g. out-of-bounds coordinates).","triggerScenarios":"Calling get_terrain with a Vector2<i32> position for which pattern_at returns Err — typically a position outside the collider grid bounds.","commonSituations":"Querying tile data at coordinates beyond the tile map bounds; iterating neighbors of edge/corner tiles without bounds checks; stale colliders data after map resize.","solutions":["Validate that the position lies within the tile map bounds before calling get_terrain.","Handle the Option::None return in caller code as 'no terrain' rather than assuming a valid id.","Ensure the colliders source is synchronized with the current tile map size.","Read the logged err message for the precise reason (usually out-of-bounds) reported by pattern_at."],"exampleFix":"// before\nlet terrain = colliders.get_terrain(&pos).unwrap();\n// after\nif let Some(terrain) = colliders.get_terrain(&pos) {\n    // use terrain\n}","handlingStrategy":"fallback","validationCode":"let in_bounds = pos.x >= 0 && pos.y >= 0;\nif !in_bounds { /* skip query */ }","typeGuard":null,"tryCatchPattern":"// get_terrain logs and returns None on failure\nmatch colliders.get_terrain(&pos) {\n    Some(t) => use_terrain(t),\n    None => Log::warn(format!(\"no terrain at {pos}, treating as empty\")),\n}","preventionTips":["Bounds-check positions before querying autotile data.","Refresh colliders data after tile map resizes.","Never unwrap the returned Option."],"tags":["fyrox","tilemap","autotile","bounds"],"backgroundTag":"index-out-of-bounds","analyzedSha":"76c91aad8eca488ce527b1af707be8b3b24ad72d","analyzedAt":"2026-09-10T16:04:01.633Z","contentChangedAt":"2026-09-10T16:04:01.633Z","schemaVersion":2},"datasetVersion":"2026-09-16T09:17:16.951Z"}