From 360a5b6017e42ea1ae057262f61996cba5d5988f Mon Sep 17 00:00:00 2001 From: Kasey White Date: Sun, 23 Oct 2022 13:39:43 -0400 Subject: [PATCH] preceding bytes output changes if you error before position 5 --- crates/uplc/src/flat.rs | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/crates/uplc/src/flat.rs b/crates/uplc/src/flat.rs index 6c4045e9..33156227 100644 --- a/crates/uplc/src/flat.rs +++ b/crates/uplc/src/flat.rs @@ -195,9 +195,11 @@ where 6 => Ok(Term::Error), 7 => Ok(Term::Builtin(DefaultFunction::decode(d)?)), x => Err(de::Error::Message(format!( - "Unknown term constructor tag: {}{} {:02X?} {} {} {} {}", + "Unknown term constructor tag: {}{}{} {} {:02X?} {} {} {} {}", x, - ".\n\nHere are the buffer bytes (5 preceding) ", + ".\n\nHere are the buffer bytes (", + if d.pos > 5 { 5 } else { d.pos }, + "preceding) ", d.buffer .iter() .skip(if d.pos - 5 > 0 { d.pos - 5 } else { 0 }) @@ -364,9 +366,11 @@ where .collect(); Err(de::Error::Message(format!( - "Unknown term constructor tag: {}{} {:02X?} {} {} {} {}", + "Unknown term constructor tag: {}{}{} {} {:02X?} {} {} {} {}", x, - ".\n\nHere are the buffer bytes (5 preceding) ", + ".\n\nHere are the buffer bytes (", + if d.pos > 5 { 5 } else { d.pos }, + "preceding) ", buffer_slice, "\n\nBuffer position is", d.pos,