mirror of
https://github.com/apple/container.git
synced 2026-10-25 08:08:29 +00:00
Add LocalizedError conformance to ContainerizationError (#528)
Without `LocalizedError` conformance, calling `localizedDescription` on a `ContainerizationError` falls back to the default representation (e.g., "ContainerizationError.ContainerizationError error 1.") instead of returning the actual error message. This makes it difficult to show meaningful errors in a UI, where `localizedDescription` is the standard way to get a user-facing string.
This commit is contained in:
1 parent
98391937da
commit
71a0b4577f
1 file changed
+7
-1
@@ -14,11 +14,13 @@
|
||||
// limitations under the License.
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
import Foundation
|
||||
|
||||
/// The core error type for Containerization.
|
||||
///
|
||||
/// Most API surfaces for the core container/process/agent types will
|
||||
/// return a ContainerizationError.
|
||||
public struct ContainerizationError: Swift.Error, Sendable {
|
||||
public struct ContainerizationError: Swift.Error, LocalizedError, Sendable {
|
||||
/// A code describing the error encountered.
|
||||
public var code: Code
|
||||
/// A description of the error.
|
||||
@@ -65,6 +67,10 @@ public struct ContainerizationError: Swift.Error, Sendable {
|
||||
public func isCode(_ code: Code) -> Bool {
|
||||
self.code == code
|
||||
}
|
||||
|
||||
public var errorDescription: String? {
|
||||
message
|
||||
}
|
||||
}
|
||||
|
||||
extension ContainerizationError: CustomStringConvertible {
|
||||
|
||||
Reference in new issue
Block a user