Skip to content

Commit 8e993ca

Browse files
crc: improve errors message
1 parent 41c7347 commit 8e993ca

File tree

5 files changed

+10
-10
lines changed

5 files changed

+10
-10
lines changed

clarity-types/src/errors/analysis.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1066,7 +1066,7 @@ impl From<CommonCheckErrorKind> for RuntimeCheckErrorKind {
10661066
}
10671067
CommonCheckErrorKind::TooManyFunctionParameters(found, allowed) => {
10681068
RuntimeCheckErrorKind::ExpectsAcceptable(format!(
1069-
"Too many function params: {found} allowed {allowed}"
1069+
"Too many function params: found {found}, allowed {allowed}"
10701070
))
10711071
}
10721072
CommonCheckErrorKind::ExpectedName => {
@@ -1100,7 +1100,7 @@ impl From<CommonCheckErrorKind> for RuntimeCheckErrorKind {
11001100
}
11011101
CommonCheckErrorKind::TraitTooManyMethods(found, allowed) => {
11021102
RuntimeCheckErrorKind::ExpectsAcceptable(format!(
1103-
"Trait too many methods: {found} allowed {allowed}"
1103+
"Trait too many methods: found {found}, allowed {allowed}"
11041104
))
11051105
}
11061106
CommonCheckErrorKind::DefineTraitBadSignature => {

clarity/src/vm/functions/define.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -603,7 +603,7 @@ mod test {
603603

604604
assert_eq!(
605605
VmExecutionError::RuntimeCheck(RuntimeCheckErrorKind::ExpectsAcceptable(
606-
"Too many function params: 257 allowed 256".to_string()
606+
"Too many function params: found 257, allowed 256".to_string()
607607
)),
608608
err
609609
);

clarity/src/vm/functions/post_conditions.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -260,7 +260,7 @@ pub fn special_restrict_assets(
260260
let allowance_list = args[1]
261261
.match_list()
262262
.ok_or(RuntimeCheckErrorKind::ExpectsAcceptable(
263-
"Expected list of allowances: restrict-assets? 2".to_string(),
263+
"Expected list of allowances: for restrict-assets? as argument 2".to_string(),
264264
))?;
265265
let body_exprs = &args[2..];
266266

@@ -274,7 +274,7 @@ pub fn special_restrict_assets(
274274

275275
if allowance_len > MAX_ALLOWANCES {
276276
return Err(RuntimeCheckErrorKind::ExpectsAcceptable(format!(
277-
"Too many allowances: {allowance_len} allowed {MAX_ALLOWANCES}"
277+
"Too many allowances: got {allowance_len}, allowed {MAX_ALLOWANCES}"
278278
))
279279
.into());
280280
}
@@ -349,7 +349,7 @@ pub fn special_as_contract(
349349
let allowance_list = args[0]
350350
.match_list()
351351
.ok_or(RuntimeCheckErrorKind::ExpectsAcceptable(
352-
"Expected list of allowances: as-contract? 1".to_string(),
352+
"Expected list of allowances: for as-contract? as argument 1".to_string(),
353353
))?;
354354
let body_exprs = &args[1..];
355355

clarity/src/vm/functions/sequences.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -351,7 +351,7 @@ pub fn special_concat_v205(
351351
runtime_cost(ClarityCostFunction::Concat, env, 1)?;
352352
return Err(RuntimeCheckErrorKind::ExpectsAcceptable(format!(
353353
"Expected sequence: {}",
354-
TypeSignature::NoType
354+
TypeSignature::type_of(&wrapped_seq)?,
355355
))
356356
.into());
357357
}

clarity/src/vm/tests/post_conditions.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1665,7 +1665,7 @@ fn restrict_assets_too_many_allowances() {
16651665
);
16661666
let max_allowances_err: ClarityEvalError =
16671667
VmExecutionError::RuntimeCheck(RuntimeCheckErrorKind::ExpectsAcceptable(format!(
1668-
"Too many allowances: {} allowed {MAX_ALLOWANCES}",
1668+
"Too many allowances: got {}, allowed {MAX_ALLOWANCES}",
16691669
MAX_ALLOWANCES + 1
16701670
)))
16711671
.into();
@@ -1739,7 +1739,7 @@ fn restrict_assets_expected_list_of_allowances() {
17391739
"#;
17401740
let expected_error: ClarityEvalError =
17411741
VmExecutionError::RuntimeCheck(RuntimeCheckErrorKind::ExpectsAcceptable(
1742-
"Expected list of allowances: restrict-assets? 2".to_string(),
1742+
"Expected list of allowances: for restrict-assets? as argument 2".to_string(),
17431743
))
17441744
.into();
17451745

@@ -1762,7 +1762,7 @@ fn as_contract_expected_list_of_allowances() {
17621762
// The argument is `u42` (not a list), so we expect this error
17631763
let expected_error: ClarityEvalError =
17641764
VmExecutionError::RuntimeCheck(RuntimeCheckErrorKind::ExpectsAcceptable(
1765-
"Expected list of allowances: as-contract? 1".to_string(),
1765+
"Expected list of allowances: for as-contract? as argument 1".to_string(),
17661766
))
17671767
.into();
17681768

0 commit comments

Comments
 (0)