This repository has been archived by the owner on Nov 1, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 510
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Move InsufficientMemory, OutOfMemory and ThreadInterrupted exceptions…
… (#18049) * Move following exceptions to shared: - InsufficientMemory, - OutOfMemory - ThreadInterrupted Related to: dotnet/coreclr#17904 Reduced diff in RegistryKey visible between coreclr and corert Signed-off-by: dotnet-bot <dotnet-bot@microsoft.com>
- Loading branch information
1 parent
58afa17
commit 872d9af
Showing
4 changed files
with
138 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
49 changes: 49 additions & 0 deletions
49
src/System.Private.CoreLib/shared/System/InsufficientMemoryException.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
// Licensed to the .NET Foundation under one or more agreements. | ||
// The .NET Foundation licenses this file to you under the MIT license. | ||
// See the LICENSE file in the project root for more information. | ||
|
||
using System; | ||
using System.Runtime.Serialization; | ||
|
||
namespace System | ||
{ | ||
/// <summary> | ||
/// Purpose: The exception class for running out of memory | ||
/// but most likely in a non-fatal way that shouldn't | ||
/// be affected by escalation policy. Use this for cases | ||
/// like MemoryFailPoint or a TryAllocate method, where you | ||
/// expect OOM's with no shared state corruption and you | ||
/// want to recover from these errors. | ||
/// </summary> | ||
[Serializable] | ||
[System.Runtime.CompilerServices.TypeForwardedFrom("mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089")] | ||
public sealed class InsufficientMemoryException : OutOfMemoryException | ||
{ | ||
public InsufficientMemoryException() : base( | ||
#if CORECLR | ||
GetMessageFromNativeResources(ExceptionMessageKind.OutOfMemory) | ||
#else | ||
SR.Arg_OutOfMemoryException | ||
#endif | ||
) | ||
{ | ||
HResult = HResults.COR_E_INSUFFICIENTMEMORY; | ||
} | ||
|
||
public InsufficientMemoryException(String message) | ||
: base(message) | ||
{ | ||
HResult = HResults.COR_E_INSUFFICIENTMEMORY; | ||
} | ||
|
||
public InsufficientMemoryException(String message, Exception innerException) | ||
: base(message, innerException) | ||
{ | ||
HResult = HResults.COR_E_INSUFFICIENTMEMORY; | ||
} | ||
|
||
private InsufficientMemoryException(SerializationInfo info, StreamingContext context) : base(info, context) | ||
{ | ||
} | ||
} | ||
} |
43 changes: 43 additions & 0 deletions
43
src/System.Private.CoreLib/shared/System/OutOfMemoryException.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
// Licensed to the .NET Foundation under one or more agreements. | ||
// The .NET Foundation licenses this file to you under the MIT license. | ||
// See the LICENSE file in the project root for more information. | ||
|
||
using System.Runtime.Serialization; | ||
|
||
namespace System | ||
{ | ||
/// <summary> | ||
/// The exception class for OOM. | ||
/// </summary> | ||
[Serializable] | ||
[System.Runtime.CompilerServices.TypeForwardedFrom("mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089")] | ||
public class OutOfMemoryException : SystemException | ||
{ | ||
public OutOfMemoryException() : base( | ||
#if CORECLR | ||
GetMessageFromNativeResources(ExceptionMessageKind.OutOfMemory) | ||
#else | ||
SR.Arg_OutOfMemoryException | ||
#endif | ||
) | ||
{ | ||
HResult = HResults.COR_E_OUTOFMEMORY; | ||
} | ||
|
||
public OutOfMemoryException(String message) | ||
: base(message) | ||
{ | ||
HResult = HResults.COR_E_OUTOFMEMORY; | ||
} | ||
|
||
public OutOfMemoryException(String message, Exception innerException) | ||
: base(message, innerException) | ||
{ | ||
HResult = HResults.COR_E_OUTOFMEMORY; | ||
} | ||
|
||
protected OutOfMemoryException(SerializationInfo info, StreamingContext context) : base(info, context) | ||
{ | ||
} | ||
} | ||
} |
43 changes: 43 additions & 0 deletions
43
src/System.Private.CoreLib/shared/System/Threading/ThreadInterruptedException.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
// Licensed to the .NET Foundation under one or more agreements. | ||
// The .NET Foundation licenses this file to you under the MIT license. | ||
// See the LICENSE file in the project root for more information. | ||
|
||
using System.Runtime.Serialization; | ||
|
||
namespace System.Threading | ||
{ | ||
/// <summary> | ||
/// An exception class to indicate that the thread was interrupted from a waiting state. | ||
/// </summary> | ||
[Serializable] | ||
[System.Runtime.CompilerServices.TypeForwardedFrom("mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089")] | ||
public class ThreadInterruptedException : SystemException | ||
{ | ||
public ThreadInterruptedException() : base( | ||
#if CORECLR | ||
GetMessageFromNativeResources(ExceptionMessageKind.ThreadInterrupted) | ||
#else | ||
SR.Threading_ThreadInterrupted | ||
#endif | ||
) | ||
{ | ||
HResult = HResults.COR_E_THREADINTERRUPTED; | ||
} | ||
|
||
public ThreadInterruptedException(String message) | ||
: base(message) | ||
{ | ||
HResult = HResults.COR_E_THREADINTERRUPTED; | ||
} | ||
|
||
public ThreadInterruptedException(String message, Exception innerException) | ||
: base(message, innerException) | ||
{ | ||
HResult = HResults.COR_E_THREADINTERRUPTED; | ||
} | ||
|
||
protected ThreadInterruptedException(SerializationInfo info, StreamingContext context) : base(info, context) | ||
{ | ||
} | ||
} | ||
} |