File tree Expand file tree Collapse file tree 1 file changed +17
-2
lines changed Expand file tree Collapse file tree 1 file changed +17
-2
lines changed Original file line number Diff line number Diff line change @@ -66,7 +66,22 @@ var pool = sync.Pool{
66
66
}
67
67
68
68
// FormatDartStandalone formats a script without dependencies on external commands
69
- func FormatDartStandalone (script string ) (string , error ) {
69
+ func FormatDartStandalone (script string ) (result string , err error ) {
70
+ defer func () {
71
+ e := recover ()
72
+
73
+ if e == nil {
74
+ return
75
+ }
76
+
77
+ if e , ok := e .(error ); ok {
78
+ err = e
79
+ return
80
+ }
81
+
82
+ err = fmt .Errorf ("%v" , e )
83
+ }()
84
+
70
85
vm := pool .Get ().(* goja.Runtime )
71
86
defer pool .Put (vm )
72
87
@@ -77,7 +92,7 @@ func FormatDartStandalone(script string) (string, error) {
77
92
}
78
93
79
94
var fn func (string ) string
80
- err : = vm .ExportTo (dartFormat , & fn )
95
+ err = vm .ExportTo (dartFormat , & fn )
81
96
if err != nil {
82
97
return "" , fmt .Errorf ("failed to execute dart_style formatter: %w" , err )
83
98
}
You can’t perform that action at this time.
0 commit comments