mirror of
https://github.com/nextcloud/android.git
synced 2024-11-24 06:05:42 +03:00
Better exception report template
With markdown now Signed-off-by: Álvaro Brey Vilas <alvaro.brey@nextcloud.com>
This commit is contained in:
parent
4cc4418bec
commit
5d07c4c6e4
2 changed files with 32 additions and 51 deletions
|
@ -63,19 +63,19 @@ class ExceptionHandler(
|
|||
private fun formatException(thread: Thread, exception: Throwable): String {
|
||||
fun formatExceptionRecursive(thread: Thread, exception: Throwable, count: Int = 0): String {
|
||||
if (count > EXCEPTION_FORMAT_MAX_RECURSIVITY) {
|
||||
return " Max number of recursive exception causes exceeded!"
|
||||
return "Max number of recursive exception causes exceeded!"
|
||||
}
|
||||
// print exception
|
||||
val stringBuilder = StringBuilder()
|
||||
val stackTrace = exception.stackTrace
|
||||
stringBuilder.appendLine(" Exception in thread \"${thread.name}\" $exception")
|
||||
stringBuilder.appendLine("Exception in thread \"${thread.name}\" $exception")
|
||||
// print available stacktrace
|
||||
for (element in stackTrace) {
|
||||
stringBuilder.appendLine(" at $element")
|
||||
stringBuilder.appendLine(" at $element")
|
||||
}
|
||||
// print cause recursively
|
||||
exception.cause?.let {
|
||||
stringBuilder.append(" Caused by: ")
|
||||
stringBuilder.append("Caused by: ")
|
||||
stringBuilder.append(formatExceptionRecursive(thread, it, count + 1))
|
||||
}
|
||||
return stringBuilder.toString()
|
||||
|
@ -87,52 +87,33 @@ class ExceptionHandler(
|
|||
private fun generateErrorReport(stackTrace: String): String {
|
||||
val buildNumber = context.resources.getString(R.string.buildNumber)
|
||||
|
||||
var buildNumberString = ""
|
||||
if (buildNumber.isNotEmpty()) {
|
||||
buildNumberString = " (build #$buildNumber)"
|
||||
val buildNumberString = when {
|
||||
buildNumber.isNotEmpty() -> " (build #$buildNumber)"
|
||||
else -> ""
|
||||
}
|
||||
|
||||
return "************ CAUSE OF ERROR ************\n\n" +
|
||||
stackTrace +
|
||||
"\n************ APP INFORMATION ************" +
|
||||
LINE_SEPARATOR +
|
||||
"ID: " +
|
||||
BuildConfig.APPLICATION_ID +
|
||||
LINE_SEPARATOR +
|
||||
"Version: " +
|
||||
BuildConfig.VERSION_CODE +
|
||||
buildNumberString +
|
||||
LINE_SEPARATOR +
|
||||
"Build flavor: " +
|
||||
BuildConfig.FLAVOR +
|
||||
LINE_SEPARATOR +
|
||||
"\n************ DEVICE INFORMATION ************" +
|
||||
LINE_SEPARATOR +
|
||||
"Brand: " +
|
||||
Build.BRAND +
|
||||
LINE_SEPARATOR +
|
||||
"Device: " +
|
||||
Build.DEVICE +
|
||||
LINE_SEPARATOR +
|
||||
"Model: " +
|
||||
Build.MODEL +
|
||||
LINE_SEPARATOR +
|
||||
"Id: " +
|
||||
Build.ID +
|
||||
LINE_SEPARATOR +
|
||||
"Product: " +
|
||||
Build.PRODUCT +
|
||||
LINE_SEPARATOR +
|
||||
"\n************ FIRMWARE ************" +
|
||||
LINE_SEPARATOR +
|
||||
"SDK: " +
|
||||
Build.VERSION.SDK_INT +
|
||||
LINE_SEPARATOR +
|
||||
"Release: " +
|
||||
Build.VERSION.RELEASE +
|
||||
LINE_SEPARATOR +
|
||||
"Incremental: " +
|
||||
Build.VERSION.INCREMENTAL +
|
||||
LINE_SEPARATOR
|
||||
return """
|
||||
|### Cause of error
|
||||
|```java
|
||||
${stackTrace.prependIndent("|")}
|
||||
|```
|
||||
|
|
||||
|### App information
|
||||
|* ID: `${BuildConfig.APPLICATION_ID}`
|
||||
|* Version: `${BuildConfig.VERSION_CODE}$buildNumberString`
|
||||
|* Build flavor: `${BuildConfig.FLAVOR}`
|
||||
|
|
||||
|### Device information
|
||||
|* Brand: `${Build.BRAND}`
|
||||
|* Device: `${Build.DEVICE}`
|
||||
|* Model: `${Build.MODEL}`
|
||||
|* Id: `${Build.ID}`
|
||||
|* Product: `${Build.PRODUCT}`
|
||||
|
|
||||
|### Firmware
|
||||
|* SDK: `${Build.VERSION.SDK_INT}`
|
||||
|* Release: `${Build.VERSION.RELEASE}`
|
||||
|* Incremental: `${Build.VERSION.INCREMENTAL}`
|
||||
""".trimMargin("|")
|
||||
}
|
||||
}
|
||||
|
|
|
@ -31,7 +31,7 @@ import com.owncloud.android.R
|
|||
import com.owncloud.android.databinding.ActivityShowErrorBinding
|
||||
import com.owncloud.android.utils.ClipboardUtil
|
||||
import com.owncloud.android.utils.DisplayUtils
|
||||
import com.owncloud.android.utils.StringUtils
|
||||
import java.net.URLEncoder
|
||||
|
||||
class ShowErrorActivity : AppCompatActivity() {
|
||||
private lateinit var binding: ActivityShowErrorBinding
|
||||
|
@ -79,7 +79,7 @@ class ShowErrorActivity : AppCompatActivity() {
|
|||
val uriUrl = Uri.parse(
|
||||
String.format(
|
||||
issueLink,
|
||||
StringUtils.escapeStacktrace(binding.textViewError.text.toString())
|
||||
URLEncoder.encode(binding.textViewError.text.toString())
|
||||
)
|
||||
)
|
||||
val intent = Intent(Intent.ACTION_VIEW, uriUrl)
|
||||
|
|
Loading…
Reference in a new issue