Skip to content
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

[devin] FlutterBeanFactoryAction add ConvertExceptionHandler #151

Merged
merged 1 commit into from
Sep 5, 2023
Merged
Changes from all 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
Original file line number Diff line number Diff line change
Expand Up @@ -76,9 +76,13 @@ class FlutterBeanFactoryAction : AnAction() {
content.append("typedef JsonConvertFunction<T> = T Function(Map<String, dynamic> json);")
content.append("\n")
content.append("typedef EnumConvertFunction<T> = T Function(String value);")
content.append("\n")
content.append("typedef ConvertExceptionHandler = void Function(Object error, StackTrace stackTrace);")
content.append("\n\n")
content.append("class JsonConvert {")
content.append("\n")
content.append("\tstatic ConvertExceptionHandler? onError;")
content.append("\n")
content.append("\tstatic Map<String, JsonConvertFunction> get convertFuncMap => {")
content.append("\n")
allClass.forEach { itemClass ->
Expand All @@ -100,6 +104,9 @@ class FlutterBeanFactoryAction : AnAction() {
" return _asT<T>(value, enumConvert: enumConvert);\n" +
" } catch (e, stackTrace) {\n" +
" debugPrint('asT<${"\$T"}> ${"\$e"} ${"\$stackTrace"}');\n" +
" if (onError != null) {" +
" onError!(e, stackTrace);" +
" }"+
" return null;\n" +
" }\n" +
" }"
Expand All @@ -114,6 +121,9 @@ class FlutterBeanFactoryAction : AnAction() {
" return value.map((dynamic e) => _asT<T>(e,enumConvert: enumConvert)).toList();\n" +
" } catch (e, stackTrace) {\n" +
" debugPrint('asT<${"\$T"}> ${"\$e"} ${"\$stackTrace"}');\n" +
" if (onError != null) {" +
" onError!(e, stackTrace);" +
" }"+
" return <T>[];\n" +
" }\n" +
" }"
Expand All @@ -128,6 +138,9 @@ class FlutterBeanFactoryAction : AnAction() {
" return (value as List<dynamic>).map((dynamic e) => _asT<T>(e,enumConvert: enumConvert)!).toList();\n" +
" } catch (e, stackTrace) {\n" +
" debugPrint('asT<${"\$T"}> ${"\$e"} ${"\$stackTrace"}');\n" +
" if (onError != null) {" +
" onError!(e, stackTrace);" +
" }"+
" return <T>[];\n" +
" }\n" +
" }"
Expand Down
Loading