@@ -180,10 +180,13 @@ impl FailWithCause for &'static str {
180
180
181
181
// FIXME #4427: Temporary until rt::rt_fail_ goes away
182
182
pub fn begin_unwind_ ( msg : * c_char , file : * c_char , line : size_t ) -> ! {
183
+ use cell:: Cell ;
183
184
use option:: Option ;
185
+ use either:: Left ;
184
186
use rt:: { context, OldTaskContext , TaskContext } ;
185
187
use rt:: task:: { Task , Unwinder } ;
186
188
use rt:: local:: Local ;
189
+ use rt:: logging:: Logger ;
187
190
188
191
let context = context ( ) ;
189
192
match context {
@@ -200,12 +203,18 @@ pub fn begin_unwind_(msg: *c_char, file: *c_char, line: size_t) -> ! {
200
203
let msg = str:: raw:: from_c_str ( msg) ;
201
204
let file = str:: raw:: from_c_str ( file) ;
202
205
203
- let outmsg = fmt ! ( "%s at line %i of file %s" , msg, line as int, file) ;
206
+ let outmsg = fmt ! ( "task failed: '%s' at line %i of file %s" ,
207
+ msg, line as int, file) ;
204
208
205
209
// XXX: Logging doesn't work correctly in non-task context because it
206
210
// invokes the local heap
207
211
if context == TaskContext {
208
- error ! ( outmsg) ;
212
+ // XXX: Logging doesn't work here - the check to call the log
213
+ // function never passes - so calling the log function directly.
214
+ let outmsg = Cell :: new ( outmsg) ;
215
+ do Local :: borrow :: < Task , ( ) > |task| {
216
+ task. logger . log ( Left ( outmsg. take ( ) ) ) ;
217
+ }
209
218
} else {
210
219
rtdebug ! ( "%s" , outmsg) ;
211
220
}
0 commit comments