Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nextcloud/mail.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/src/util
diff options
context:
space:
mode:
authorChristoph Wurst <christoph@winzerhof-wurst.at>2018-11-09 14:44:54 +0300
committerChristoph Wurst <christoph@winzerhof-wurst.at>2018-11-09 14:44:54 +0300
commit0d28b38aec170fb700a9290ff831279854824bee (patch)
tree6a23870e039e36f059e49225d1eb1dc992ac509b /src/util
parentaa829b84fbdfed64bde77f32904f36627c7bb27d (diff)
Handle message loading errors and revive crash reporter
Signed-off-by: Christoph Wurst <christoph@winzerhof-wurst.at>
Diffstat (limited to 'src/util')
-rw-r--r--src/util/CrashReport.js70
1 files changed, 70 insertions, 0 deletions
diff --git a/src/util/CrashReport.js b/src/util/CrashReport.js
new file mode 100644
index 000000000..a1f218f04
--- /dev/null
+++ b/src/util/CrashReport.js
@@ -0,0 +1,70 @@
+/*
+ * @copyright 2018 Christoph Wurst <christoph@winzerhof-wurst.at>
+ *
+ * @author 2018 Christoph Wurst <christoph@winzerhof-wurst.at>
+ *
+ * @license GNU AGPL version 3 or any later version
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+import IssueTemplateBuilder from 'nextcloud_issuetemplate_builder'
+
+const flattenError = error => {
+ let text = ''
+ if (error.type) {
+ text += error.type + ': '
+ }
+ text += error.message
+ text += '\n'
+ if (error.trace) {
+ text += flattenTrace(error.trace)
+ }
+ if (error.stack) {
+ text += error.stack
+ }
+ return text
+}
+
+const flattenTrace = trace => {
+ return trace.reduce(function (acc, entry) {
+ var text = ''
+ if (entry.class) {
+ text += ' at ' + entry.class + '::' + entry.function
+ } else {
+ text += ' at ' + entry.function
+ }
+ if (entry.file) {
+ text += '\n ' + entry.file + ', line ' + entry.line
+ }
+ return acc + text + '\n'
+ }, '')
+}
+
+export const getReportUrl = error => {
+ console.error(error)
+ var message = error.message || 'An unkown error occurred.'
+ if (!message.endsWith('.')) {
+ message += '.'
+ }
+ var builder = new IssueTemplateBuilder()
+ var template = builder.addEmptyStepsToReproduce()
+ .addExpectedActualBehaviour()
+ .addLogs('Error', flattenError(error))
+ .render()
+
+ return 'https://github.com/nextcloud/mail/issues/new' +
+ '?title=' + encodeURIComponent(message) +
+ '&body=' + encodeURIComponent(template)
+}