From fa235f64a1adf95ce0e92fbb55a815324c8eca7a Mon Sep 17 00:00:00 2001 From: breandan Date: Tue, 30 Apr 2024 13:52:37 -0400 Subject: [PATCH] catch clipboard error --- .../ai/hypergraph/kaliningraph/visualization/Utils.kt | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/jvmMain/kotlin/ai/hypergraph/kaliningraph/visualization/Utils.kt b/src/jvmMain/kotlin/ai/hypergraph/kaliningraph/visualization/Utils.kt index b29484f5..603e8dcd 100644 --- a/src/jvmMain/kotlin/ai/hypergraph/kaliningraph/visualization/Utils.kt +++ b/src/jvmMain/kotlin/ai/hypergraph/kaliningraph/visualization/Utils.kt @@ -29,9 +29,11 @@ fun MutableGraph.render(format: Format, layout: Engine = DOT): Renderer = toGraphviz().apply { engine(layout) }.render(format) fun String.alsoCopy() = also { - StringSelection(this).let { - Toolkit.getDefaultToolkit().systemClipboard.setContents(it, it) - } + try { + StringSelection(this).let { + Toolkit.getDefaultToolkit().systemClipboard.setContents(it, it) + } + } catch (e: Exception) { println("Error copying to clipboard: $e") } } fun String.show() = File.createTempFile("" + hashCode(), ".html")