1e19ebb4d9
移动端 network.status 读取失败返回稳定 host_error 响应 移动壳网络测试覆盖 Expo Network 异常不透出原生消息 移动壳配置检查反查网络状态失败边界
17 lines
478 B
TypeScript
17 lines
478 B
TypeScript
import { getMobileNetworkStatus } from '../shell/network';
|
|
import { type HostBridgeRequest } from '../../../../packages/shared/src/contracts/hostBridge';
|
|
import { failure, ok } from './protocol';
|
|
|
|
export async function getMobileHostBridgeNetworkStatus(
|
|
request: HostBridgeRequest,
|
|
) {
|
|
try {
|
|
return ok(request, await getMobileNetworkStatus());
|
|
} catch {
|
|
return failure(request, {
|
|
code: 'host_error',
|
|
message: 'network status unavailable',
|
|
});
|
|
}
|
|
}
|