From 211f9171e0dceb6a734412c5f930594eb7679a5d Mon Sep 17 00:00:00 2001 From: Armin Ronacher Date: Sat, 24 Mar 2018 02:11:04 +0100 Subject: [PATCH] feat: Added modules to exceptions --- src/protocol/v7.rs | 4 ++++ tests/test_protocol_v7.rs | 21 ++++++++++++--------- 2 files changed, 16 insertions(+), 9 deletions(-) diff --git a/src/protocol/v7.rs b/src/protocol/v7.rs index 7e987d6e..79a5eb4d 100644 --- a/src/protocol/v7.rs +++ b/src/protocol/v7.rs @@ -186,6 +186,7 @@ pub struct Thread { pub current: bool, } + /// Represents a single exception #[derive(Serialize, Deserialize, Debug, Default, Clone, PartialEq)] pub struct Exception { @@ -195,6 +196,9 @@ pub struct Exception { /// The optional value of the exception #[serde(skip_serializing_if = "Option::is_none")] pub value: Option, + /// An optional module for this exception. + #[serde(skip_serializing_if = "Option::is_none")] + pub module: Option, /// Optionally the stacktrace. #[serde(skip_serializing_if = "Option::is_none")] pub stacktrace: Option, diff --git a/tests/test_protocol_v7.rs b/tests/test_protocol_v7.rs index 526e1b73..80c6796e 100644 --- a/tests/test_protocol_v7.rs +++ b/tests/test_protocol_v7.rs @@ -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 { @@ -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 { @@ -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 { @@ -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]}}]}}" ); }