mirror of
https://github.com/PostHog/posthog.git
synced 2024-11-29 11:12:33 +01:00
fix(err): limit context line length (#26397)
This commit is contained in:
parent
c0db78bee8
commit
94c2b0a456
@ -108,8 +108,8 @@ pub struct Context {
|
||||
|
||||
#[derive(Debug, Clone, Serialize, Deserialize, Eq, PartialEq)]
|
||||
pub struct ContextLine {
|
||||
pub number: u32,
|
||||
pub line: String,
|
||||
number: u32,
|
||||
line: String,
|
||||
}
|
||||
|
||||
impl Frame {
|
||||
@ -155,9 +155,16 @@ impl Frame {
|
||||
|
||||
impl ContextLine {
|
||||
pub fn new(number: u32, line: impl ToString) -> Self {
|
||||
let line = line.to_string();
|
||||
// We limit context line length to 300 chars
|
||||
let mut constrained: String = line.to_string().chars().take(300).collect();
|
||||
if line.len() > constrained.len() {
|
||||
constrained.push_str("...✂️");
|
||||
}
|
||||
|
||||
Self {
|
||||
number,
|
||||
line: line.to_string(),
|
||||
line: constrained,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user