Skip to content

Generate Report with exception #142

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Aug 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Backtrace.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ Pod::Spec.new do |s|
s.osx.public_header_files = ["Backtrace-macOS/**/*.h*"]
s.tvos.public_header_files = ["Backtrace-tvOS/**/*.h*"]
s.static_framework = true
s.dependency "PLCrashReporter", '1.11'
s.dependency "PLCrashReporter", '1.11.1'
s.resource_bundle = { 'BacktraceResources' => ['Sources/**/*.xcdatamodeld','Sources/Resources/*.xcprivacy']}

end
4 changes: 2 additions & 2 deletions Package.resolved

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ let package = Package(
.library(name: "Backtrace", targets: ["Backtrace"])
],
dependencies: [
.package(url: "https://github.com/microsoft/plcrashreporter.git", from: "1.11.0"),
.package(url: "https://github.com/microsoft/plcrashreporter.git", .exact("1.11.1")),
.package(url: "https://github.com/Quick/Nimble.git", from: "10.0.0"),
.package(url: "https://github.com/Quick/Quick.git", from: "5.0.1")
],
Expand Down
2 changes: 1 addition & 1 deletion Podfile
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ project 'Backtrace.xcworkspace'
# Definitions
def shared_pods
# Define shared CocoaPods here
pod 'PLCrashReporter', '1.11'
pod 'PLCrashReporter', '1.11.1'
end

def shared_test_pods
Expand Down
12 changes: 6 additions & 6 deletions Podfile.lock
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
PODS:
- Backtrace (2.0.5-alpha1):
- PLCrashReporter (= 1.11)
- PLCrashReporter (= 1.11.1)
- Nimble (10.0.0)
- PLCrashReporter (1.11.0)
- PLCrashReporter (1.11.1)
- Quick (5.0.1)

DEPENDENCIES:
- Backtrace (from `./Backtrace.podspec`)
- Nimble (~> 10.0.0)
- PLCrashReporter (= 1.11)
- PLCrashReporter (= 1.11.1)
- Quick (~> 5.0.1)

SPEC REPOS:
Expand All @@ -22,11 +22,11 @@ EXTERNAL SOURCES:
:path: "./Backtrace.podspec"

SPEC CHECKSUMS:
Backtrace: fd2750f1fae07c5fe5540543fdbf8c46ec0280c9
Backtrace: 060b3cf69aa69a4a080d1e713f8b3047f932d921
Nimble: 5316ef81a170ce87baf72dd961f22f89a602ff84
PLCrashReporter: 7a9dff14a23ba5d2e28c6160f0bb6fada5e71a8d
PLCrashReporter: 5d2d3967afe0efad61b3048d617e2199a5d1b787
Quick: 749aa754fd1e7d984f2000fe051e18a3a9809179

PODFILE CHECKSUM: 9879217fb9b028733c19f11520859f8869f67aba
PODFILE CHECKSUM: 57ff1dc221e0d36eb96c410cf8f411fed4e969f5

COCOAPODS: 1.15.2
3 changes: 2 additions & 1 deletion Sources/Public/BacktraceCrashReporter.swift
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,8 @@ extension BacktraceCrashReporter: CrashReporting {
attributes: Attributes,
attachmentPaths: [String] = []) throws -> BacktraceReport {

return try BacktraceReport(report: reporter.generateLiveReport(), attributes: attributes, attachmentPaths: attachmentPaths)
let reportData = try reporter.generateLiveReport(with: exception)
return try BacktraceReport(report: reportData, attributes: attributes, attachmentPaths: attachmentPaths)
}

func enableCrashReporting() throws {
Expand Down
15 changes: 15 additions & 0 deletions Tests/CrashReporterTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,26 @@ final class CrashReporterTests: QuickSpec {
it("generates live report on demand") {
expect { try crashReporter.generateLiveReport(attributes: [:]) }.toNot(throwError())
}

it("generate live report on demand 10 times") {
for _ in 0...10 {
expect { try crashReporter.generateLiveReport(attributes: [:]) }.toNot(throwError())
}
}

it("generated live report without exception") {
let reportData = try crashReporter.generateLiveReport(exception: nil, attributes: [:])

expect { reportData.plCrashReport.exceptionInfo }.to(beNil())
}

it("generated live report contains exception") {
let exception = NSException(name: NSExceptionName.decimalNumberOverflowException, reason: "Test Spec")
let reportData = try crashReporter.generateLiveReport(exception: exception, attributes: [:])

expect { reportData.plCrashReport.exceptionInfo.exceptionName }.to(equal(NSExceptionName.decimalNumberOverflowException.rawValue))
expect { reportData.plCrashReport.exceptionInfo.exceptionReason }.to(equal("Test Spec"))
}
}
}
}
Expand Down
Loading