Skip to content

Commit

Permalink
Fix error message in Go de-jsonization of strings (#512)
Browse files Browse the repository at this point in the history
We erroneously copy-pasted the error message from the function for
de-serialization of booleans to the function for de-serialization of
strings, misleading the user of the generated code.

This patch fixes the issue.
  • Loading branch information
mristin authored Jul 20, 2024
1 parent b537610 commit 06ec988
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions aas_core_codegen/golang/jsonization/_generate.py
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ def _generate_string_from_jsonable() -> Stripped:
{II}return
{I}}} else {{
{II}err = newDeserializationError(
{III}fmt.Sprintf("Expected a boolean, but got %T", jsonable),
{III}fmt.Sprintf("Expected a string, but got %T", jsonable),
{II})
{II}return
{I}}}
Expand Down Expand Up @@ -1416,7 +1416,7 @@ def _generate_to_jsonable(symbol_table: intermediate.SymbolTable) -> Stripped:

return Stripped(
f"""\
// Serialize ``that`` instance to a JSON-able representation.
// Serialize that instance to a JSON-able representation.
//
// Return a structure which can be readily converted to JSON,
// or an error if some value could not be converted.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ func stringFromJsonable(
return
} else {
err = newDeserializationError(
fmt.Sprintf("Expected a boolean, but got %T", jsonable),
fmt.Sprintf("Expected a string, but got %T", jsonable),
)
return
}
Expand Down Expand Up @@ -20859,7 +20859,7 @@ func dataSpecificationIEC61360ToMap(
return
}

// Serialize ``that`` instance to a JSON-able representation.
// Serialize that instance to a JSON-able representation.
//
// Return a structure which can be readily converted to JSON,
// or an error if some value could not be converted.
Expand Down

0 comments on commit 06ec988

Please sign in to comment.