Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commita0c26d0

Browse files
committed
improve error handling
1 parente7db8e4 commita0c26d0

File tree

2 files changed

+15
-10
lines changed

2 files changed

+15
-10
lines changed

‎Coder-Desktop/Coder-Desktop/URLHandler.swift

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import Foundation
2+
import SwiftUI
23
import VPNLib
34

45
@MainActor
@@ -29,32 +30,36 @@ class URLHandler {
2930

3031
switch route{
3132
caselet.open(workspace, agent, type):
32-
switch type{
33-
caselet.rdp(creds):
34-
tryhandleRDP(workspace: workspace, agent: agent, creds: creds)
33+
do{
34+
switch type{
35+
caselet.rdp(creds):
36+
tryhandleRDP(workspace: workspace, agent: agent, creds: creds)
37+
}
38+
}catch{
39+
throw.openError(error)
3540
}
3641
}
3742
}
3843

39-
privatefunc handleRDP(workspace:String, agent:String, creds:RDPCredentials)throws(URLError){
44+
privatefunc handleRDP(workspace:String, agent:String, creds:RDPCredentials)throws(OpenError){
4045
guard vpn.state==.connectedelse{
41-
throw.openError(.coderConnectOffline)
46+
throw.coderConnectOffline
4247
}
4348

4449
guardlet workspace= vpn.menuState.findWorkspace(name: workspace)else{
45-
throw.openError(.invalidWorkspace(workspace: workspace))
50+
throw.invalidWorkspace(workspace: workspace)
4651
}
4752

4853
guardlet agent= vpn.menuState.findAgent(workspaceID: workspace.id, name: agent)else{
49-
throw.openError(.invalidAgent(workspace: workspace.name, agent: agent))
54+
throw.invalidAgent(workspace: workspace.name, agent: agent)
5055
}
5156

5257
varrdpString="rdp:full address=s:\(agent.primaryHost):3389"
5358
iflet username= creds.username{
5459
rdpString+="&username=s:\(username)"
5560
}
5661
guardlet url=URL(string: rdpString)else{
57-
throw.openError(.couldNotCreateRDPURL(rdpString))
62+
throw.couldNotCreateRDPURL(rdpString)
5863
}
5964

6065
letalert=NSAlert()

‎Coder-Desktop/VPNLib/CoderRouter.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ public enum RouterError: Error {
3535
case noSession
3636
case openError(OpenError)
3737

38-
vardescription:String{
38+
publicvardescription:String{
3939
switchself{
4040
caselet.invalidAuthority(authority):
4141
"Authority '\(authority)' does not match the host of the current Coder deployment."
@@ -48,7 +48,7 @@ public enum RouterError: Error {
4848
}
4949
}
5050

51-
varlocalizedDescription:String{ description}
51+
publicvarlocalizedDescription:String{ description}
5252
}
5353

5454
publicenumOpenError:Error{

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp