Skip to content

Commit

Permalink
catch clipboard error
Browse files Browse the repository at this point in the history
  • Loading branch information
breandan committed Apr 30, 2024
1 parent d5cb019 commit fa235f6
Showing 1 changed file with 5 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down

0 comments on commit fa235f6

Please sign in to comment.