()
| 375 | } |
| 376 | |
| 377 | async function localProviderMetadata() { |
| 378 | let health = null; |
| 379 | let healthError = null; |
| 380 | try { |
| 381 | health = await localJson("/api/health"); |
| 382 | } catch (error) { |
| 383 | healthError = error; |
| 384 | health = null; |
| 385 | } |
| 386 | |
| 387 | try { |
| 388 | const simulators = await localJson("/api/simulators"); |
| 389 | const selected = |
| 390 | simulators.simulators?.find((simulator) => simulator.isBooted) ?? |
| 391 | simulators.simulators?.[0] ?? |
| 392 | null; |
| 393 | return { health, ok: true, simulator: selected }; |
| 394 | } catch (error) { |
| 395 | if (health) { |
| 396 | return { health, ok: true, simulator: null }; |
| 397 | } |
| 398 | return { |
| 399 | failureReason: localProviderFailureReason(healthError, error), |
| 400 | health: null, |
| 401 | ok: false, |
| 402 | simulator: null, |
| 403 | }; |
| 404 | } |
| 405 | } |
| 406 | |
| 407 | function localProviderFailureReason(healthError, simulatorError) { |
| 408 | const healthMessage = describeError(healthError); |
no test coverage detected