Skip to content

Commit

Permalink
Refactor error presentation in setting lists
Browse files Browse the repository at this point in the history
  • Loading branch information
1024jp committed Mar 2, 2025
1 parent a35dbf5 commit 73e75b4
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
// ---------------------------------------------------------------------------
//
// © 2004-2007 nakamuxu
// © 2014-2024 1024jp
// © 2014-2025 1024jp
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -489,12 +489,9 @@ final class SyntaxListViewController: NSViewController, NSMenuItemValidation, NS

do {
try SyntaxManager.shared.removeSetting(name: name)

} catch {
alert.window.orderOut(nil)
NSSound.beep()
await NSAlert(error: error).beginSheetModal(for: window)
return
return self.presentErrorAsSheet(error)
}

AudioServicesPlaySystemSound(.moveToTrash)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
// ---------------------------------------------------------------------------
//
// © 2004-2007 nakamuxu
// © 2014-2024 1024jp
// © 2014-2025 1024jp
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -322,7 +322,7 @@ final class ThemeListViewController: NSViewController, NSMenuItemValidation, NST
fieldEditor.string = oldName

// show alert
NSAlert(error: error).beginSheetModal(for: self.view.window!)
self.presentErrorAsSheet(error)
return false
}

Expand Down Expand Up @@ -538,12 +538,9 @@ final class ThemeListViewController: NSViewController, NSMenuItemValidation, NST

do {
try ThemeManager.shared.removeSetting(name: name)

} catch {
alert.window.orderOut(nil)
NSSound.beep()
await NSAlert(error: error).beginSheetModal(for: window)
return
return self.presentErrorAsSheet(error)
}

AudioServicesPlaySystemSound(.moveToTrash)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ final class MultipleReplaceListViewController: NSViewController, NSMenuItemValid
do {
try ReplacementManager.shared.createUntitledSetting()
} catch {
NSAlert(error: error).beginSheetModal(for: self.view.window!)
self.presentErrorAsSheet(error)
}
}

Expand Down Expand Up @@ -365,12 +365,9 @@ final class MultipleReplaceListViewController: NSViewController, NSMenuItemValid

do {
try ReplacementManager.shared.removeSetting(name: name)

} catch {
alert.window.orderOut(nil)
NSSound.beep()
await NSAlert(error: error).beginSheetModal(for: window)
return
return self.presentErrorAsSheet(error)
}

AudioServicesPlaySystemSound(.moveToTrash)
Expand Down Expand Up @@ -598,7 +595,7 @@ extension MultipleReplaceListViewController: NSTextFieldDelegate {
fieldEditor.string = oldName

// show alert
NSAlert(error: error).beginSheetModal(for: self.view.window!)
self.presentErrorAsSheet(error)
return false
}

Expand Down

0 comments on commit 73e75b4

Please sign in to comment.