Skip to content

Serialization error due to unknown language(s) #47

@MCOfficer

Description

@MCOfficer

If DeepL detects a language the library doesn't know about, it might respond like this:

{
  "translations" : [ {
    "text" : "[omitted]",
    "detected_source_language" : "CEB",
    "tag_handling_version" : "V1"
  } ]
}

Which causes the following error:

InvalidResponse(
    "convert json bytes to Rust type: error decoding response body",
)

The custom error message at

format!("invalid language code {lang}. This is an internal issue with the lib, please open issue")

is missing.


Taking a step back, can the serialization in general be improved to be less prone to errors?
Maybe an unknown language could serialize to something like Lang::UNKNOWN(String)? Or would using an ISO-693 crate be better, to cover all possible codes?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions