| OLD | NEW |
| (Empty) |
| 1 // Copyright (c) 2015, the Dartino project authors. Please see the AUTHORS file | |
| 2 // for details. All rights reserved. Use of this source code is governed by a | |
| 3 // BSD-style license that can be found in the LICENSE.md file. | |
| 4 | |
| 5 library fletchc.please_report_crash; | |
| 6 | |
| 7 import 'guess_configuration.dart' show | |
| 8 fletchVersion; | |
| 9 | |
| 10 bool crashReportRequested = false; | |
| 11 | |
| 12 final String requestBugReportOnCompilerCrashMessage = """ | |
| 13 The Dartino compiler is broken. | |
| 14 | |
| 15 When compiling the above element, the compiler crashed. It is not | |
| 16 possible to tell if this is caused by a problem in your program or | |
| 17 not. Regardless, the compiler should not crash. | |
| 18 | |
| 19 The Dartino team would greatly appreciate if you would take a moment to | |
| 20 report this problem at https://github.com/dartino/sdk/issues/new | |
| 21 | |
| 22 Please include the following information: | |
| 23 | |
| 24 * the name and version of your operating system | |
| 25 | |
| 26 * the Dartino SDK version ($fletchVersion) | |
| 27 | |
| 28 * the entire message you see here (including the full stack trace | |
| 29 below as well as the source location above) | |
| 30 """; | |
| 31 | |
| 32 final String requestBugReportOnOtherCrashMessage = """ | |
| 33 The Dartino program is broken and has crashed. | |
| 34 | |
| 35 The Dartino team would greatly appreciate if you would take a moment to | |
| 36 report this problem at https://github.com/dartino/sdk/issues/new | |
| 37 | |
| 38 Please include the following information: | |
| 39 | |
| 40 * the name and version of your operating system | |
| 41 | |
| 42 * the Dartino SDK version ($fletchVersion) | |
| 43 | |
| 44 * the entire message you see here (including the full stack trace below) | |
| 45 """; | |
| 46 | |
| 47 void pleaseReportCrash(error, StackTrace trace) { | |
| 48 String formattedError = stringifyError(error, trace); | |
| 49 if (!crashReportRequested) { | |
| 50 crashReportRequested = true; | |
| 51 print("$requestBugReportOnOtherCrashMessage$formattedError"); | |
| 52 } else { | |
| 53 print(formattedError); | |
| 54 } | |
| 55 } | |
| 56 | |
| 57 String stringifyError(error, StackTrace stackTrace) { | |
| 58 String safeToString(object) { | |
| 59 try { | |
| 60 return '$object'; | |
| 61 } catch (e) { | |
| 62 return Error.safeToString(object); | |
| 63 } | |
| 64 } | |
| 65 StringBuffer buffer = new StringBuffer(); | |
| 66 buffer.writeln(safeToString(error)); | |
| 67 if (stackTrace != null) { | |
| 68 buffer.writeln(safeToString(stackTrace)); | |
| 69 } else { | |
| 70 buffer.writeln("No stack trace."); | |
| 71 } | |
| 72 return '$buffer'; | |
| 73 } | |
| OLD | NEW |