Skip to content

Commit

Permalink
Fix error messages
Browse files Browse the repository at this point in the history
  • Loading branch information
afsalthaj committed Oct 2, 2024
1 parent 9d9e99c commit 0044a1e
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
8 changes: 4 additions & 4 deletions golem-rib/src/compiler/byte_code.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1035,7 +1035,7 @@ mod compiler_tests {
let compiler_error = compiler::compile(&expr, &metadata).unwrap_err();
assert_eq!(
compiler_error,
"Invalid resource method call golem:it/api.{cart(user_id).foo}. `foo` doesn't exist in resource `cart`"
"Unknown resource method call golem:it/api.{cart(user_id).foo}. `foo` doesn't exist in resource `cart`"
);
}

Expand Down Expand Up @@ -1112,7 +1112,7 @@ mod compiler_tests {
let compiler_error = compiler::compile(&expr, &metadata).unwrap_err();
assert_eq!(
compiler_error,
"Invalid argument type in function `foo`. Expected type `str`, but provided argument `1u64` is a `number`"
"Invalid type for the argument in function `foo`. Expected type `str`, but provided argument `1u64` is a `number`"
);
}

Expand All @@ -1129,7 +1129,7 @@ mod compiler_tests {
let compiler_error = compiler::compile(&expr, &metadata).unwrap_err();
assert_eq!(
compiler_error,
"Invalid arguments type in resource method `golem:it/api.{cart(user_id).add-item}`. Expected type `record`, but provided argument `\"apple\"` is a `str`"
"Invalid type for the argument in resource method `golem:it/api.{cart(user_id).add-item}`. Expected type `record`, but provided argument `\"apple\"` is a `str`"
);
}

Expand All @@ -1145,7 +1145,7 @@ mod compiler_tests {
let compiler_error = compiler::compile(&expr, &metadata).unwrap_err();
assert_eq!(
compiler_error,
"Invalid argument type in resource constructor `cart`. Expected type `str`, but provided argument `{foo: \"bar\"}` is a `record`"
"Invalid type for the argument in resource constructor `cart`. Expected type `str`, but provided argument `{foo: \"bar\"}` is a `record`"
);
}
}
Expand Down
10 changes: 5 additions & 5 deletions golem-rib/src/type_inference/call_arguments_inference.rs
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ mod internal {
),
ArgTypesInferenceError::TypeMisMatchError { expected, provided } => {
format!(
"Invalid argument type in resource constructor `{}`. Expected type `{}`, but provided argument `{}` is a `{}`",
"Invalid type for the argument in resource constructor `{}`. Expected type `{}`, but provided argument `{}` is a `{}`",
resource_name, expected.get_type_kind(), provided, provided.inferred_type().get_type_kind()
)
}
Expand All @@ -119,7 +119,7 @@ mod internal {
inferred_type,
).map_err(|e| match e {
ArgTypesInferenceError::UnknownFunction => {
format!("Invalid resource method call {}. `{}` doesn't exist in resource `{}`", parsed_function_static, parsed_function_static.function.resource_method_name().unwrap(), resource_name)
format!("Unknown resource method call {}. `{}` doesn't exist in resource `{}`", parsed_function_static, parsed_function_static.function.resource_method_name().unwrap(), resource_name)
}
ArgTypesInferenceError::ArgumentSizeMisMatch {
expected,
Expand All @@ -130,7 +130,7 @@ mod internal {
),
ArgTypesInferenceError::TypeMisMatchError { expected, provided } => {
format!(
"Invalid arguments type in resource method `{}`. Expected type `{}`, but provided argument `{}` is a `{}`",
"Invalid type for the argument in resource method `{}`. Expected type `{}`, but provided argument `{}` is a `{}`",
parsed_function_static, expected.get_type_kind(), provided, provided.inferred_type().get_type_kind()
)
}
Expand All @@ -156,7 +156,7 @@ mod internal {
),
ArgTypesInferenceError::TypeMisMatchError { expected, provided } => {
format!(
"Invalid argument type in function `{}`. Expected type `{}`, but provided argument `{}` is a `{}`",
"Invalid type for the argument in function `{}`. Expected type `{}`, but provided argument `{}` is a `{}`",
parsed_function_static.function.function_name(), expected.get_type_kind(), provided, provided.inferred_type().get_type_kind()
)
}
Expand Down Expand Up @@ -193,7 +193,7 @@ mod internal {
),
ArgTypesInferenceError::TypeMisMatchError { expected, provided } => {
format!(
"Invalid argument type in variant `{}`. Expected type `{}`, but provided argument `{}` is a `{}`",
"Invalid type for the argument in variant `{}`. Expected type `{}`, but provided argument `{}` is a `{}`",
variant_name, expected.get_type_kind(), provided, provided.inferred_type().get_type_kind()
)
}
Expand Down

0 comments on commit 0044a1e

Please sign in to comment.