@@ -304,33 +304,20 @@ private void OnMessageReceived(CompilerMessage message)
304304 }
305305
306306 compilation . endedAt = Interface . Oxide . Now ;
307- string stdOutput = ( string ) message . ExtraData ;
308- if ( stdOutput != null )
307+ Log ( LogType . Info , $ "Compiler returned data for compilation { compilation . name } (Took: { Math . Round ( ( compilation . endedAt - compilation . startedAt ) * 1000f ) } ms) | Errors: { message . Errors ? . Count } ") ;
308+
309+ if ( message . Errors != null )
309310 {
310- foreach ( string line in stdOutput . Split ( new [ ] { '\r ' , '\n ' } ,
311- StringSplitOptions . RemoveEmptyEntries ) )
311+ foreach ( CompilerError error in message . Errors )
312312 {
313- Match match = Constants . FileErrorRegex . Match ( line . Trim ( ) ) ;
314- if ( ! match . Success )
315- {
316- continue ;
317- }
313+ Log ( LogType . Error , $ "Compiler error for compilation { compilation . name } : { error . Message } ") ;
318314
319- if ( match . Groups [ "Severity" ] . Value != "Error" )
320- {
321- continue ;
322- }
323-
324- string fileName = match . Groups [ "File" ] . Value ;
325- string scriptName = Path . GetFileNameWithoutExtension ( fileName ) ;
326- string error = match . Groups [ "Message" ] . Value ;
327-
328- CompilablePlugin compilablePlugin =
329- compilation . plugins . SingleOrDefault ( pl => pl . ScriptName == scriptName ) ;
315+ CompilablePlugin ? compilablePlugin =
316+ compilation . plugins . SingleOrDefault ( pl => pl . ScriptName == error . File ) ;
330317
331318 if ( compilablePlugin == null )
332319 {
333- Interface . Oxide . LogError ( $ "Unable to resolve script error to { fileName } : { error } ") ;
320+ Interface . Oxide . LogError ( $ "Unable to resolve script error to { error . File } : { error . Message } ") ;
334321 continue ;
335322 }
336323
@@ -342,13 +329,14 @@ private void OnMessageReceived(CompilerMessage message)
342329 {
343330 compilablePlugin . CompilerErrors = $ "Missing dependencies: { string . Join ( "," , missingRequirementsArray ) } ";
344331
345- Log ( LogType . Error , $ "[{ match . Groups [ "Severity" ] . Value } ][ { scriptName } ] Missing dependencies: { string . Join ( "," , missingRequirementsArray ) } ") ;
332+ Log ( LogType . Error , $ "[{ error . File } ] Missing dependencies: { string . Join ( "," , missingRequirementsArray ) } ") ;
346333 }
347334 else
348335 {
349- compilablePlugin . CompilerErrors = error . Trim ( )
350- . Replace ( Interface . Oxide . PluginDirectory + Path . DirectorySeparatorChar ,
351- string . Empty ) ;
336+ // TODO: Allow multiple errors
337+ compilablePlugin . CompilerErrors = error . Message ;
338+
339+ Log ( LogType . Error , $ "[{ error . File } ] { error . Message } ") ;
352340 }
353341 }
354342 }
@@ -369,19 +357,21 @@ private void OnMessageReceived(CompilerMessage message)
369357 }
370358 case MessageType . Error :
371359 {
372- string exception = message . ExtraData ;
373360 Compilation compilation = _compilations [ message . Id ] ;
374361 _compilations . Remove ( message . Id ) ;
375362
363+ CompilerError ? compilerError = message ? . Errors ? [ 0 ] ;
364+ string errorMessage = compilerError ? . Message ?? "Unknown error occurred in compiler" ;
365+
376366 if ( compilation == null )
377367 {
378- Interface . Oxide . LogError ( $ "Compiler returned a error for a untracked compilation: { exception } ") ;
368+ Interface . Oxide . LogError ( $ "Compiler returned a error for a untracked compilation: { errorMessage } ") ;
379369 return ;
380370 }
381371
382372 foreach ( CompilablePlugin p in compilation . plugins )
383373 {
384- p . CompilerErrors = exception ;
374+ p . CompilerErrors = errorMessage ;
385375 }
386376
387377 compilation . Completed ( ) ;
0 commit comments