Skip to content

Commit f890c8d

Browse files
Update src/Immediate.Cache.Shared/Owned.cs
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
1 parent d851d76 commit f890c8d

1 file changed

Lines changed: 10 additions & 2 deletions

File tree

src/Immediate.Cache.Shared/Owned.cs

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,15 @@ IServiceScopeFactory serviceScopeFactory
3737
public OwnedScope<T> GetScope(out T service)
3838
{
3939
var scope = serviceScopeFactory.CreateAsyncScope();
40-
service = scope.ServiceProvider.GetRequiredService<T>();
41-
return new(service, scope);
40+
try
41+
{
42+
service = scope.ServiceProvider.GetRequiredService<T>();
43+
return new(service, scope);
44+
}
45+
catch
46+
{
47+
scope.Dispose();
48+
throw;
49+
}
4250
}
4351
}

0 commit comments

Comments
 (0)