Switch to using .catch(()=>{}) instead of try catch
This commit is contained in:
		
							parent
							
								
									61cc4a19f3
								
							
						
					
					
						commit
						1b97351ca0
					
				
					 1 changed files with 9 additions and 9 deletions
				
			
		| 
						 | 
					@ -129,15 +129,15 @@ class Form extends ElemJS {
 | 
				
			||||||
		this.status(`Looking up homeserver... trying ${address}`)
 | 
							this.status(`Looking up homeserver... trying ${address}`)
 | 
				
			||||||
	
 | 
						
 | 
				
			||||||
		// Check if we found the actual matrix server
 | 
							// Check if we found the actual matrix server
 | 
				
			||||||
		try {
 | 
							const versionsReq = await fetch(`${address}/_matrix/client/versions`).catch(()=>{})
 | 
				
			||||||
			const versionsReq = await fetch(`${address}/_matrix/client/versions`)
 | 
							/* jshint ignore:start */
 | 
				
			||||||
			if(versionsReq.ok) {
 | 
							//JsHint doesn't support optional chaining
 | 
				
			||||||
				const versions = await versionsReq.json()
 | 
							// https://github.com/jshint/jshint/issues/3448
 | 
				
			||||||
				if (Array.isArray(versions.versions)) {
 | 
							if(versionsReq?.ok) {
 | 
				
			||||||
					return address
 | 
								const versions = await versionsReq.json().catch(()=>{})
 | 
				
			||||||
				}
 | 
								if (Array.isArray(versions?.versions)) return address
 | 
				
			||||||
			}
 | 
							}
 | 
				
			||||||
		} catch(e) {}
 | 
							/* jshint ignore:end */
 | 
				
			||||||
	
 | 
						
 | 
				
			||||||
		// find the next matrix server in the chain
 | 
							// find the next matrix server in the chain
 | 
				
			||||||
		const root = await fetch(`${address}/.well-known/matrix/client`).then(res => res.json()).catch(e => {
 | 
							const root = await fetch(`${address}/.well-known/matrix/client`).then(res => res.json()).catch(e => {
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue