我通过调用 Gson.fromJson() 得到了 com.google.gson.JsonSyntaxException ,因此添加了 catch(Exception) 逻辑,但错误永远不会被捕获,而只是被抛出!
这是我所拥有的:
Request request = new Request.Builder()
.url(getOrderUrlWithId)
.get()
.build();
try {
Response response = this.okHttpClient.newCall(request).execute();
GetOrderResult orderResult = gson.fromJson(gson.toJson(response.body().string()), GetOrderResult.class);
response.close();
} catch (IOException e) {
log.error("Error retrieving order : " + e.getMessage(), e);
throw new RuntimeException(e);
} catch (Exception e) {
log.error("Error happening for client PO: " + clientPO, e);
return null;
}
Run Code Online (Sandbox Code Playgroud)
当我运行测试时,我得到“com.google.gson.JsonSyntaxException:java.lang.IllegalStateException:预期BEGIN_OBJECT,但在第1行第1列路径$为STRING”
为什么错误没有被捕获?
这是堆栈跟踪:
com.google.gson.JsonSyntaxException: java.lang.IllegalStateException: Expected BEGIN_OBJECT but was STRING at line 1 column 1 path $
at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory$Adapter.read(ReflectiveTypeAdapterFactory.java:226) …Run Code Online (Sandbox Code Playgroud) 我目前能够从 Flutter 中的 Home 应用程序 MaterialRoute 到页面,并显示弹出对话框。但是,从第二页路由到第三页(其中包含一个应该显示对话框的按钮)时,我收到此错误:[VERBOSE-2:ui_dart_state.cc(157)] Unhandled Exception: 'package:flutter/src/widgets/localizations.dart': Failed assertion: line 446 pos 12: 'context != null': is not true.
触发该错误的 showDialogue 如下所示:
class ThirdPageWidgetState extends State<ThirdPageWidget> {
StreamSubscription<ScanResult> scanSubscription;
@override
void initState() {
super.initState();
}
Future<void> alert(deviceName) async {
return showDialog<void>(
barrierDismissible: false, // user must tap button!
builder: (BuildContext context) {
return AlertDialog(
title: Text('Button Pressed!'),
content: SingleChildScrollView(
child: ListBody(
children: <Widget>[
Text('test'),
],
),
),
actions: <Widget>[
FlatButton(
child: Text('Ok'),
),
],
);
}, …Run Code Online (Sandbox Code Playgroud) 使用 Flask_Admin,我有一个视图/模型Movie,它将有一个字段genre,该字段将是一个字符串,要么是"horror","action"要么是"comedy"。对于 Flask_admin 中的电影创建表单,我有:
class MovieView(ModelView):
column_list = ['id', 'name', 'genre', 'director']
form_create_rules = ('name', 'genre', 'director')
Run Code Online (Sandbox Code Playgroud)
但“电影创建”表单的“流派”字段显示为空白。如何添加占位符值以便管理员知道要在该字段中放入哪些值?
正如标题所示,我选择不使用负载均衡器,但对于 SSL 支持,您需要负载均衡器。是否可以向我的 Elastic Beanstalk 应用程序添加负载均衡器?或者我必须重新配置一个全新的应用程序?
ssl load-balancing amazon-web-services amazon-elastic-beanstalk
我正在 Flutter+Dart 中编写一个移动应用程序,并且能够渲染用户的帐户信息,但我一直坚持如何循环遍历列表以填充和渲染带有该列表中的对象的表,就在用户帐户下方信息。
这是我的“容器”,我希望不使用类似的索引videos.removeAt(0)并以某种方式循环遍历所有索引来videos填充表。
Widget build(BuildContext context) {
List<Video> videos = Video.getVideosFromJson(jsonDecode(json));
return Container(
child: Column(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: <Widget>[
Text('Account Info for ' + customer.firstName + ' ' + customer.lastName),
Container(
child: Padding(
padding: const EdgeInsets.all(14.0),
//TODO: HERE IS THE TABLE, I WISH TO DUPLICATE THESE ROWS FOR EACH "VIDEO" IN "List<Video> videos"
child: Table(
border: TableBorder.all(width: 1.0, color: Colors.black),
children: [
TableRow(children: [
TableCell(
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceAround,
children: <Widget>[
new Text('VideoId'),
new Text(videos.removeAt(0).id.toString()), …Run Code Online (Sandbox Code Playgroud)