Skip to content

Show critical error with more details #103

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Feb 24, 2025
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 3 additions & 9 deletions lib/openvino_console_app.dart
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
import 'package:go_router/go_router.dart';
import 'package:inference/deployment_processor.dart';
import 'package:inference/interop/device.dart';
import 'package:inference/interop/image_inference.dart';
import 'package:inference/providers/preference_provider.dart';
import 'package:inference/providers/project_provider.dart';
import 'package:inference/utils.dart';
Expand Down Expand Up @@ -36,16 +35,11 @@
void initState() {
super.initState();

//setLoggingOutput();
ensureFontIsStored().then((_) {
fontPath().then((font) => ImageInference.setupFont(font));
});

setupErrors();

Device.getDevices().then((devices) {
Device.getDevices() .then((devices) {

Check warning on line 39 in lib/openvino_console_app.dart

View check run for this annotation

Codecov / codecov/patch

lib/openvino_console_app.dart#L39

Added line #L39 was not covered by tests
PreferenceProvider.availableDevices = devices;
});
ensureFontIsStored();

Check warning on line 42 in lib/openvino_console_app.dart

View check run for this annotation

Codecov / codecov/patch

lib/openvino_console_app.dart#L42

Added line #L42 was not covered by tests

final projectsProvider = Provider.of<ProjectProvider>(context, listen: false);
final addProjects = projectsProvider.addProjects;
Expand Down Expand Up @@ -197,7 +191,7 @@
right: 24,
bottom: 24,
child: FeedbackButton()
)
),
],
);
}
Expand Down
3 changes: 1 addition & 2 deletions lib/pages/download_model/download_model.dart
Original file line number Diff line number Diff line change
Expand Up @@ -84,8 +84,7 @@
request = DownloadRequest(
id: widget.project.id,
downloads: files,
);
request!.onDone = onComplete;
)..onDone = onComplete;

Check warning on line 87 in lib/pages/download_model/download_model.dart

View check run for this annotation

Codecov / codecov/patch

lib/pages/download_model/download_model.dart#L87

Added line #L87 was not covered by tests
setState(() {});
projectProvider.addProject(widget.project);
await getAdditionalModelInfo(widget.project);
Expand Down
18 changes: 17 additions & 1 deletion lib/utils.dart
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,13 @@
import 'package:dio/dio.dart';
import 'package:dio/io.dart';
import 'package:file_picker/file_picker.dart';
import 'package:fluent_ui/fluent_ui.dart';
import 'package:flutter/foundation.dart';
import 'package:inference/config.dart';
import 'package:inference/deployment_processor.dart';
import 'package:inference/project.dart';
import 'package:inference/router.dart';
import 'package:inference/widgets/dialogs/critical_error.dart';
import 'package:intl/intl.dart';
import 'package:path/path.dart';
import 'package:path_provider/path_provider.dart';
Expand Down Expand Up @@ -46,6 +49,18 @@
return '';
}


Future<T?> showGlobalDialog<T extends Object?>(WidgetBuilder builder) async {
if (rootNavigatorKey.currentContext?.mounted == true) {
return await showDialog(
context: rootNavigatorKey.currentContext!,

Check warning on line 56 in lib/utils.dart

View check run for this annotation

Codecov / codecov/patch

lib/utils.dart#L53-L56

Added lines #L53 - L56 were not covered by tests
builder: builder
);
} else {
return null;
}
}

void setupErrors() async {
final directory = await getApplicationSupportDirectory();
final platformContext = Context(style: Style.platform);
Expand All @@ -71,6 +86,7 @@
""";
print(contents);
File(errorPath).writeAsStringSync(contents, mode: FileMode.append);
showCriticalErrorDialog(error, stack);

Check warning on line 89 in lib/utils.dart

View check run for this annotation

Codecov / codecov/patch

lib/utils.dart#L89

Added line #L89 was not covered by tests
return true;
};
}
Expand Down Expand Up @@ -109,4 +125,4 @@
}
return '';
}
}
}
43 changes: 43 additions & 0 deletions lib/widgets/dialogs/critical_error.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
import 'package:fluent_ui/fluent_ui.dart';

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
import 'package:fluent_ui/fluent_ui.dart';
// Copyright (c) 2024 Intel Corporation
//
// SPDX-License-Identifier: Apache-2.0
import 'package:fluent_ui/fluent_ui.dart';

import 'package:inference/utils.dart';

void showCriticalErrorDialog(dynamic e, StackTrace trace) {
showGlobalDialog((context) => ContentDialog(

Check warning on line 5 in lib/widgets/dialogs/critical_error.dart

View check run for this annotation

Codecov / codecov/patch

lib/widgets/dialogs/critical_error.dart#L4-L5

Added lines #L4 - L5 were not covered by tests
constraints: const BoxConstraints(
maxWidth: 756,
maxHeight: 500,
),
title: const Text("An error occured."),
content: Column(

Check warning on line 11 in lib/widgets/dialogs/critical_error.dart

View check run for this annotation

Codecov / codecov/patch

lib/widgets/dialogs/critical_error.dart#L11

Added line #L11 was not covered by tests
crossAxisAlignment: CrossAxisAlignment.start,
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
SizedBox(

Check warning on line 15 in lib/widgets/dialogs/critical_error.dart

View check run for this annotation

Codecov / codecov/patch

lib/widgets/dialogs/critical_error.dart#L14-L15

Added lines #L14 - L15 were not covered by tests
height: 50,
child: Padding(

Check warning on line 17 in lib/widgets/dialogs/critical_error.dart

View check run for this annotation

Codecov / codecov/patch

lib/widgets/dialogs/critical_error.dart#L17

Added line #L17 was not covered by tests
padding: const EdgeInsets.all(8.0),
child: Text(e.toString(), overflow: TextOverflow.ellipsis),

Check warning on line 19 in lib/widgets/dialogs/critical_error.dart

View check run for this annotation

Codecov / codecov/patch

lib/widgets/dialogs/critical_error.dart#L19

Added line #L19 was not covered by tests
),
),
Expander(

Check warning on line 22 in lib/widgets/dialogs/critical_error.dart

View check run for this annotation

Codecov / codecov/patch

lib/widgets/dialogs/critical_error.dart#L22

Added line #L22 was not covered by tests
header: const Text("Details"),
content: SizedBox(

Check warning on line 24 in lib/widgets/dialogs/critical_error.dart

View check run for this annotation

Codecov / codecov/patch

lib/widgets/dialogs/critical_error.dart#L24

Added line #L24 was not covered by tests
height: 180,
child: SingleChildScrollView(
child: SelectableText("$e\n$trace")),

Check warning on line 27 in lib/widgets/dialogs/critical_error.dart

View check run for this annotation

Codecov / codecov/patch

lib/widgets/dialogs/critical_error.dart#L26-L27

Added lines #L26 - L27 were not covered by tests
)
),
],
),
actions: <Widget>[
Button(
onPressed: () {
Navigator.pop(context, true);

Check warning on line 35 in lib/widgets/dialogs/critical_error.dart

View check run for this annotation

Codecov / codecov/patch

lib/widgets/dialogs/critical_error.dart#L32-L35

Added lines #L32 - L35 were not covered by tests
//windowManager.close();
},
child: const Text('Close'),
),
]
)
);
}
Loading