Skip to content

Commit cffd458

Browse files
committed
[PlaygroundLogger] Began introducing limited error handling.
Made `CustomOpaqueLoggable` and `PlaygroundQuickLook.opaqueRepresentation()` into throwing operations, as converting to an opaque representation may fail. This means that creating a `LogEntry` may fail outright if the subject cannot provide its opaque representation. Further, that means that both structural log entries and `LogPacket` may now contain error log entries representing cases when generating the opaque representation fails. Note that this is not full error handling, as many errors occur during the encoding process rather than during `LogEntry` generation.
1 parent 4804597 commit cffd458

25 files changed

+109
-94
lines changed

PlaygroundLogger/PlaygroundLogger/CustomLoggable/AppKit/NSBitmapImageRep+CustomOpaqueLoggable.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
//
33
// This source file is part of the Swift.org open source project
44
//
5-
// Copyright (c) 2017 Apple Inc. and the Swift project authors
5+
// Copyright (c) 2017-2018 Apple Inc. and the Swift project authors
66
// Licensed under Apache License v2.0 with Runtime Library Exception
77
//
88
// See http://swift.org/LICENSE.txt for license information
@@ -14,7 +14,7 @@
1414
import AppKit
1515

1616
extension NSBitmapImageRep: CustomOpaqueLoggable {
17-
var opaqueRepresentation: LogEntry.OpaqueRepresentation {
17+
func opaqueRepresentation() -> LogEntry.OpaqueRepresentation {
1818
return ImageOpaqueRepresentation(kind: .image, backedBy: self)
1919
}
2020
}

PlaygroundLogger/PlaygroundLogger/CustomLoggable/AppKit/NSColor+CustomOpaqueLoggable.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
//
33
// This source file is part of the Swift.org open source project
44
//
5-
// Copyright (c) 2017 Apple Inc. and the Swift project authors
5+
// Copyright (c) 2017-2018 Apple Inc. and the Swift project authors
66
// Licensed under Apache License v2.0 with Runtime Library Exception
77
//
88
// See http://swift.org/LICENSE.txt for license information
@@ -14,7 +14,7 @@
1414
import AppKit
1515

1616
extension NSColor: CustomOpaqueLoggable {
17-
var opaqueRepresentation: LogEntry.OpaqueRepresentation {
17+
func opaqueRepresentation() -> LogEntry.OpaqueRepresentation {
1818
return self.cgColor
1919
}
2020
}

PlaygroundLogger/PlaygroundLogger/CustomLoggable/AppKit/NSCursor+CustomOpaqueLoggable.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
//
33
// This source file is part of the Swift.org open source project
44
//
5-
// Copyright (c) 2017 Apple Inc. and the Swift project authors
5+
// Copyright (c) 2017-2018 Apple Inc. and the Swift project authors
66
// Licensed under Apache License v2.0 with Runtime Library Exception
77
//
88
// See http://swift.org/LICENSE.txt for license information
@@ -14,7 +14,7 @@
1414
import AppKit
1515

1616
extension NSCursor: CustomOpaqueLoggable {
17-
var opaqueRepresentation: LogEntry.OpaqueRepresentation {
17+
func opaqueRepresentation() -> LogEntry.OpaqueRepresentation {
1818
return ImageOpaqueRepresentation(kind: .image, backedBy: self.image)
1919
}
2020
}

PlaygroundLogger/PlaygroundLogger/CustomLoggable/AppKit/NSImage+CustomOpaqueLoggable.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
//
33
// This source file is part of the Swift.org open source project
44
//
5-
// Copyright (c) 2017 Apple Inc. and the Swift project authors
5+
// Copyright (c) 2017-2018 Apple Inc. and the Swift project authors
66
// Licensed under Apache License v2.0 with Runtime Library Exception
77
//
88
// See http://swift.org/LICENSE.txt for license information
@@ -14,7 +14,7 @@
1414
import AppKit
1515

1616
extension NSImage: CustomOpaqueLoggable {
17-
var opaqueRepresentation: LogEntry.OpaqueRepresentation {
17+
func opaqueRepresentation() -> LogEntry.OpaqueRepresentation {
1818
return ImageOpaqueRepresentation(kind: .image, backedBy: self)
1919
}
2020
}

PlaygroundLogger/PlaygroundLogger/CustomLoggable/AppKit/NSView+CustomOpaqueLoggable.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
//
33
// This source file is part of the Swift.org open source project
44
//
5-
// Copyright (c) 2017 Apple Inc. and the Swift project authors
5+
// Copyright (c) 2017-2018 Apple Inc. and the Swift project authors
66
// Licensed under Apache License v2.0 with Runtime Library Exception
77
//
88
// See http://swift.org/LICENSE.txt for license information
@@ -14,7 +14,7 @@
1414
import AppKit
1515

1616
extension NSView: CustomOpaqueLoggable {
17-
var opaqueRepresentation: LogEntry.OpaqueRepresentation {
17+
func opaqueRepresentation() -> LogEntry.OpaqueRepresentation {
1818
return ImageOpaqueRepresentation(kind: .view, backedBy: self)
1919
}
2020
}

PlaygroundLogger/PlaygroundLogger/CustomLoggable/CoreGraphics/CGFloat+CustomOpaqueLoggable.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
import CoreGraphics
1414

1515
extension CGFloat: CustomOpaqueLoggable {
16-
var opaqueRepresentation: LogEntry.OpaqueRepresentation {
16+
func opaqueRepresentation() -> LogEntry.OpaqueRepresentation {
1717
return self.native
1818
}
1919
}

PlaygroundLogger/PlaygroundLogger/CustomLoggable/CoreGraphics/CGImage+CustomOpaqueLoggable.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
//
33
// This source file is part of the Swift.org open source project
44
//
5-
// Copyright (c) 2017 Apple Inc. and the Swift project authors
5+
// Copyright (c) 2017-2018 Apple Inc. and the Swift project authors
66
// Licensed under Apache License v2.0 with Runtime Library Exception
77
//
88
// See http://swift.org/LICENSE.txt for license information
@@ -13,7 +13,7 @@
1313
import CoreGraphics
1414

1515
extension CGImage: CustomOpaqueLoggable {
16-
var opaqueRepresentation: LogEntry.OpaqueRepresentation {
16+
func opaqueRepresentation() -> LogEntry.OpaqueRepresentation {
1717
return ImageOpaqueRepresentation(kind: .image, backedBy: self)
1818
}
1919
}

PlaygroundLogger/PlaygroundLogger/CustomLoggable/CoreImage/CIColor+CustomOpaqueLoggable.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
//
33
// This source file is part of the Swift.org open source project
44
//
5-
// Copyright (c) 2017 Apple Inc. and the Swift project authors
5+
// Copyright (c) 2017-2018 Apple Inc. and the Swift project authors
66
// Licensed under Apache License v2.0 with Runtime Library Exception
77
//
88
// See http://swift.org/LICENSE.txt for license information
@@ -13,7 +13,7 @@
1313
import CoreImage
1414

1515
extension CIColor: CustomOpaqueLoggable {
16-
var opaqueRepresentation: LogEntry.OpaqueRepresentation {
16+
func opaqueRepresentation() throws -> LogEntry.OpaqueRepresentation {
1717
guard let color = CGColor(colorSpace: self.colorSpace, components: self.components) else {
1818
loggingError("Unable to convert CIColor to CGColor")
1919
}

PlaygroundLogger/PlaygroundLogger/CustomLoggable/CoreImage/CIImage+CustomOpaqueLoggable.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
//
33
// This source file is part of the Swift.org open source project
44
//
5-
// Copyright (c) 2017 Apple Inc. and the Swift project authors
5+
// Copyright (c) 2017-2018 Apple Inc. and the Swift project authors
66
// Licensed under Apache License v2.0 with Runtime Library Exception
77
//
88
// See http://swift.org/LICENSE.txt for license information
@@ -20,7 +20,7 @@ import CoreGraphics
2020
#endif
2121

2222
extension CIImage: CustomOpaqueLoggable {
23-
var opaqueRepresentation: LogEntry.OpaqueRepresentation {
23+
func opaqueRepresentation() -> LogEntry.OpaqueRepresentation {
2424
if let cgImage = self.cgImage {
2525
return ImageOpaqueRepresentation(kind: .image, backedBy: cgImage)
2626
}

PlaygroundLogger/PlaygroundLogger/CustomLoggable/CustomOpaqueLoggable.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
//
33
// This source file is part of the Swift.org open source project
44
//
5-
// Copyright (c) 2017 Apple Inc. and the Swift project authors
5+
// Copyright (c) 2017-2018 Apple Inc. and the Swift project authors
66
// Licensed under Apache License v2.0 with Runtime Library Exception
77
//
88
// See http://swift.org/LICENSE.txt for license information
@@ -11,11 +11,11 @@
1111
//===----------------------------------------------------------------------===//
1212

1313
protocol CustomOpaqueLoggable {
14-
var opaqueRepresentation: LogEntry.OpaqueRepresentation { get }
14+
func opaqueRepresentation() throws -> LogEntry.OpaqueRepresentation
1515
}
1616

1717
extension CustomOpaqueLoggable where Self: LogEntry.OpaqueRepresentation {
18-
var opaqueRepresentation: LogEntry.OpaqueRepresentation {
18+
func opaqueRepresentation() -> LogEntry.OpaqueRepresentation {
1919
return self
2020
}
2121
}

0 commit comments

Comments
 (0)