- r - 以节省内存的方式增长 data.frame
- ruby-on-rails - ruby/ruby on rails 内存泄漏检测
- android - 无法解析导入android.support.v7.app
- UNIX 域套接字与共享内存(映射文件)
我正在使用 HTTP dart 包 在 flutter 中执行这样的发布请求,但有时当网络出现故障时,IOClient 会抛出 ClientException类,但我在 catch block 和应用程序崩溃中没有得到任何东西。
http.post(url, headers: headers, body: body).then((response) {
//response parsing
}).catchError((error) {
//ClientException is never catched in this block.
});
最佳答案
如package:http/src/io_client.dart
中所述:
Any internal HTTP errors should be wrapped as [ClientException]s.
如 docs 中所述这是一个明显的例子:
Potential problem: accidentally mixing synchronous and asynchronous errors
要解决此问题,您需要将代码包装在 Future.sync() 中。
Future.sync() makes your code resilient against uncaught exceptions. If your function has a lot of code packed into it, chances are that you could be doing something dangerous without realizing it:
return new Future.sync(() {
http.post(url, headers: headers, body: body).then((response) {});
});
Future.sync() not only allows you to handle errors you know might occur, but also prevents errors from accidentally leaking out of your function.
关于android - Flutter-dart http 库 ClientException,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52515258/
我不确定如何进行这项工作。我也无法在我的应用程序中找到 client_id。我只看到那里的应用程序 secret : >>> import praw >>> r = praw.Reddit(user_
由于 SocketTimeoutException 读取超时,我面临以下 ZuulException 异常。我试图将我的 oauth2 服务器放在 zuul 代理后面。请查看日志跟踪 here ,网关
我正在使用 HTTP dart 包 在 flutter 中执行这样的发布请求,但有时当网络出现故障时,IOClient 会抛出 ClientException类,但我在 catch block 和应用
当我尝试使用 Subclipse 比较 Eclipse 中的文件时,我收到以下错误消息: Unsupported working copy format svn: This client is too
我正在尝试开发一个Flutter(Web)应用程序,该应用程序需要调用访问受限的HTTP触发的云函数。 因此,我已经在我的Google云控制台中创建了一个服务帐户,并遵循了有关如何检索经过身份验证的h
这是异常(exception):ClientException:找不到ffmpeg。 该机器人托管在 replit 中,一直运行良好,这是一个新事物。 我必须做什么? async def play_m
我在自定义提供程序中使用redis类,但在服务器上不起作用。 在本地没有任何问题,但我不明白为什么它在服务器上不起作用。 当我使用工匠命令时,出现此错误。 “Predis \ ClientExcept
我正在尝试使用 Vision Cognitive Services 来接收图像的描述,但我的代码总是抛出此异常: Exception Microsoft.ProjectOxford.Vision.Cl
我正在尝试制作一个在语音 channel 中播放音乐的 discord 机器人。它连接到语音 channel ,但不播放任何内容。它还会在控制台中给出错误。 我在 Windows 上,我正在使用 di
我是 flutter/dart 的新用户,正在将 Android 原生应用程序转换为 flutter。 我正在对我(在 LUA 中)编写的物联网设备(NodeMCU ESP8266)进行 REST 调
这是server.js: const express = require("express"); const cors = require("cors"); const axios = require
这是server.js: const express = require("express"); const cors = require("cors"); const axios = require
SVN出现提示org.apache.subversion.javahl.ClientException: Attempted to lock an already-locked dir解决方案 第
我有一个 Spring boot 应用程序,该应用程序的实体在字段上具有唯一性约束。 我正在运行 spring-boot、spring-data-neo4j、neo4j-ogm、bolt-driver
我是 PHP 的绝对初学者(我来自 Java),我有以下与如何处理异常相关的问题。 我正在使用 Guzzle 执行对 REST 网络服务的调用,如下所示: $client = new Clie
我是 PHP 的绝对初学者(我来自 Java),我有以下与如何处理异常相关的问题。 我正在使用 Guzzle 执行对 REST 网络服务的调用,如下所示: $client = new Clie
我 try catch 异常,但我仍然在 C:\OS\OpenServer\domains\kinopoisk\parser\php\vendor 中收到“ fatal error :未捕获异常‘Gu
我是 SSL 的新手,所以如果我问了任何愚蠢的问题,请坦白。 我正在开发一个处理信用卡交易的 Java EE 网络应用程序。在这里,我尝试使用来自 cybersource 的 p12 证书。 我有一个
我正在设置 Laravel 应用程序以向 Google 进行身份验证。 系统提示我选择一个 Google 帐户并允许访问我的 Google 信息,我已准备好回调函数。 当我的回调函数运行时(它确实被正
我是一名优秀的程序员,十分优秀!