-
Notifications
You must be signed in to change notification settings - Fork 30
Expand file tree
/
Copy pathErrorDetailPanel.swift
More file actions
43 lines (36 loc) · 1.2 KB
/
ErrorDetailPanel.swift
File metadata and controls
43 lines (36 loc) · 1.2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
//
// ErrorDetailPanel.swift
// Tophat
//
// Created by Lukas Romsicki on 2026-03-11.
// Copyright © 2026 Shopify. All rights reserved.
//
import AppKit
/// A panel that displays technical error details in a scrollable,
/// selectable text view. Intended to be shown from an alert's
/// "Show Details" button.
final class ErrorDetailPanel: NSPanel {
init(detail: String) {
super.init(
contentRect: NSRect(x: 0, y: 0, width: 500, height: 300),
styleMask: [.titled, .closable, .miniaturizable, .resizable],
backing: .buffered,
defer: true
)
title = "Error Details"
isReleasedWhenClosed = false
isFloatingPanel = true
hidesOnDeactivate = false
minSize = NSSize(width: 300, height: 150)
standardWindowButton(.zoomButton)?.isHidden = true
let scrollView = NSTextView.scrollableTextView()
scrollView.frame = contentView!.bounds
scrollView.autoresizingMask = [.width, .height]
let textView = scrollView.documentView as! NSTextView
textView.isEditable = false
textView.font = .monospacedSystemFont(ofSize: NSFont.smallSystemFontSize, weight: .regular)
textView.string = detail
textView.textContainerInset = NSSize(width: 8, height: 8)
contentView?.addSubview(scrollView)
}
}