From aeb0b42c7a8f77f8372e82c176f98f0ea13c8765 Mon Sep 17 00:00:00 2001 From: Nathan Sobo Date: Tue, 5 Apr 2022 13:53:13 -0600 Subject: [PATCH] Report more information when we panic due to an allocation failure --- crates/gpui/src/platform/mac/atlas.rs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/crates/gpui/src/platform/mac/atlas.rs b/crates/gpui/src/platform/mac/atlas.rs index 5e87474bf1..33f6fc19db 100644 --- a/crates/gpui/src/platform/mac/atlas.rs +++ b/crates/gpui/src/platform/mac/atlas.rs @@ -2,6 +2,7 @@ use crate::geometry::{ rect::RectI, vector::{vec2i, Vector2I}, }; +use anyhow::anyhow; use etagere::BucketedAtlasAllocator; use foreign_types::ForeignType; use metal::{Device, TextureDescriptor}; @@ -48,7 +49,12 @@ impl AtlasAllocator { .allocate(requested_size) .unwrap_or_else(|| { let mut atlas = self.new_atlas(requested_size); - let (id, origin) = atlas.allocate(requested_size).unwrap(); + let (id, origin) = atlas + .allocate(requested_size) + .ok_or_else(|| { + anyhow!("could not allocate requested size {:?}", requested_size) + }) + .unwrap(); self.atlases.push(atlas); (id, origin) });