mirror of
https://github.com/apple/container.git
synced 2026-07-12 20:47:04 +00:00
Add cause string to error message sent with xpc (#361)
Looks like we've been ignoring the "cause" field for ContainerizationError when sent over xpc. Add the cause to the `ContainerXPCError` message field instead of a new `cause` field since `Error` is not encodable. The goal here is just to preserve information. Signed-off-by: Kathryn Baldauf <k_baldauf@apple.com>
This commit is contained in:
@@ -86,7 +86,11 @@ extension XPCMessage {
|
||||
}
|
||||
|
||||
public func set(error: ContainerizationError) {
|
||||
let serializableError = ContainerXPCError(code: error.code.description, message: error.message)
|
||||
var message = error.message
|
||||
if let cause = error.cause {
|
||||
message += " (cause: \"\(cause)\")"
|
||||
}
|
||||
let serializableError = ContainerXPCError(code: error.code.description, message: message)
|
||||
let data = try? JSONEncoder().encode(serializableError)
|
||||
precondition(data != nil)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user