Skip to content

Commit

Permalink
feat: Added modules to exceptions
Browse files Browse the repository at this point in the history
  • Loading branch information
mitsuhiko committed Mar 24, 2018
1 parent 7f84b13 commit 211f917
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 9 deletions.
4 changes: 4 additions & 0 deletions src/protocol/v7.rs
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,7 @@ pub struct Thread {
pub current: bool,
}


/// Represents a single exception
#[derive(Serialize, Deserialize, Debug, Default, Clone, PartialEq)]
pub struct Exception {
Expand All @@ -195,6 +196,9 @@ pub struct Exception {
/// The optional value of the exception
#[serde(skip_serializing_if = "Option::is_none")]
pub value: Option<String>,
/// An optional module for this exception.
#[serde(skip_serializing_if = "Option::is_none")]
pub module: Option<String>,
/// Optionally the stacktrace.
#[serde(skip_serializing_if = "Option::is_none")]
pub stacktrace: Option<Stacktrace>,
Expand Down
21 changes: 12 additions & 9 deletions tests/test_protocol_v7.rs
Original file line number Diff line number Diff line change
Expand Up @@ -352,6 +352,7 @@ fn test_minimal_exception_stacktrace() {
exceptions: vec![v7::Exception {
ty: "DivisionByZero".into(),
value: Some("integer division or modulo by zero".into()),
module: None,
stacktrace: Some(v7::Stacktrace {
frames: vec![
v7::Frame {
Expand Down Expand Up @@ -385,6 +386,7 @@ fn test_slightly_larger_exception_stacktrace() {
exceptions: vec![v7::Exception {
ty: "DivisionByZero".into(),
value: Some("integer division or modulo by zero".into()),
module: None,
stacktrace: Some(v7::Stacktrace {
frames: vec![
v7::Frame {
Expand Down Expand Up @@ -432,6 +434,7 @@ fn test_full_exception_stacktrace() {
exceptions: vec![v7::Exception {
ty: "DivisionByZero".into(),
value: Some("integer division or modulo by zero".into()),
module: Some("x".into()),
stacktrace: Some(v7::Stacktrace {
frames: vec![
v7::Frame {
Expand Down Expand Up @@ -471,14 +474,14 @@ fn test_full_exception_stacktrace() {

assert_eq!(
serde_json::to_string(&event).unwrap(),
"{\"exception\":{\"values\":[{\"type\":\"DivisionByZero\",\"value\":\
\"integer division or modulo by zero\",\"stacktrace\":{\"frames\":\
[{\"function\":\"main\",\"symbol\":\"main\",\"module\":\"hello\",\
\"package\":\"hello.whl\",\"filename\":\"hello.py\",\"abs_path\":\
\"/app/hello.py\",\"lineno\":7,\"colno\":42,\"pre_context\":\
[\"foo\",\"bar\"],\"context_line\":\"hey hey hey\",\"post_context\":\
[\"foo\",\"bar\"],\"in_app\":true,\"vars\":{\"var\":\"value\"},\
\"image_addr\":0,\"instruction_addr\":0,\"symbol_addr\":0}],\
\"frames_omitted\":[1,2]}}]}}"
"{\"exception\":{\"values\":[{\"type\":\"DivisionByZero\",\
\"value\":\"integer division or modulo by zero\",\"module\":\
\"x\",\"stacktrace\":{\"frames\":[{\"function\":\"main\",\"symbol\":\
\"main\",\"module\":\"hello\",\"package\":\"hello.whl\",\"filename\":\
\"hello.py\",\"abs_path\":\"/app/hello.py\",\"lineno\":7,\"\
colno\":42,\"pre_context\":[\"foo\",\"bar\"],\"context_line\":\
\"hey hey hey\",\"post_context\":[\"foo\",\"bar\"],\"in_app\":true,\
\"vars\":{\"var\":\"value\"},\"image_addr\":0,\"instruction_addr\":0,\
\"symbol_addr\":0}],\"frames_omitted\":[1,2]}}]}}"
);
}

0 comments on commit 211f917

Please sign in to comment.