This repository was archived by the owner on Sep 30, 2020. It is now read-only.
File tree Expand file tree Collapse file tree 1 file changed +20
-10
lines changed Expand file tree Collapse file tree 1 file changed +20
-10
lines changed Original file line number Diff line number Diff line change 84
84
// console.log("Sending", data);
85
85
req . open ( 'POST' , "https://play.rust-lang.org/evaluate.json" , true ) ;
86
86
req . onload = function ( e ) {
87
+ var statusCode = false ;
88
+ var result = null ;
89
+
87
90
if ( req . readyState === 4 && req . status === 200 ) {
88
- var result = JSON . parse ( req . response ) . result ;
91
+ result = JSON . parse ( req . response ) ;
89
92
90
- // Need server support to get an accurate version of this.
91
- var statusCode = SUCCESS ;
92
- if ( result . indexOf ( "error:" ) !== - 1 ) {
93
+ // handle application errors from playpen
94
+ if ( typeof result [ 'error' ] === 'string' ) {
93
95
statusCode = ERROR ;
94
- } else if ( result . indexOf ( "warning:" ) !== - 1 ) {
95
- statusCode = WARNING ;
96
+ result = 'Playpen Error: ' + result [ 'error' ] ;
97
+ } else if ( typeof result [ 'result' ] === 'string' ) {
98
+ statusCode = SUCCESS ;
99
+ result = result [ 'result' ] ;
100
+
101
+ // handle rustc errors/warnings
102
+ // Need server support to get an accurate version of this.
103
+ if ( result . indexOf ( "error:" ) !== - 1 ) {
104
+ statusCode = ERROR ;
105
+ } else if ( result . indexOf ( "warning:" ) !== - 1 ) {
106
+ statusCode = WARNING ;
107
+ }
96
108
}
97
-
98
- callback ( statusCode , result ) ;
99
- } else {
100
- callback ( false , null ) ;
101
109
}
110
+
111
+ callback ( statusCode , result ) ;
102
112
} ;
103
113
104
114
req . onerror = function ( e ) {
You can’t perform that action at this time.
0 commit comments