File tree Expand file tree Collapse file tree 1 file changed +13
-14
lines changed Expand file tree Collapse file tree 1 file changed +13
-14
lines changed Original file line number Diff line number Diff line change @@ -390,20 +390,19 @@ module ConversionResult = {
390390 let decode = (~fromLang : Lang .t , ~toLang : Lang .t , json ): t => {
391391 open JSON
392392 switch json {
393- | Object (dict {
394- "type" : String (type_ ),
395- "msg" : ?Some (String (msg )),
396- "errors" : ?Some (Array (errors )),
397- }) =>
398- switch type_ {
399- | "success" => Success (ConvertSuccess .decode (json ))
400- | "unexpected_error" => msg -> UnexpectedError
401- | "syntax_error" =>
402- let locMsgs = errors -> Array .map (LocMsg .decode )
403- Fail ({fromLang , toLang , details : locMsgs })
404- | other => Unknown (` Unknown conversion result type "${other}"` , json )
405- }
406- | _ => throw (Failure (` Failed to decode ConversionResult. ${__LOC__}` ))
393+ | Object (dict {"type" : String ("success" )}) => Success (ConvertSuccess .decode (json ))
394+ | Object (dict {"type" : String ("unexpected_error" ), "msg" : String (msg )}) => UnexpectedError (msg )
395+ | Object (dict {"type" : String ("syntax_error" ), "errors" : Array (errors )}) =>
396+ let locMsgs = errors -> Array .map (LocMsg .decode )
397+ Fail ({fromLang , toLang , details : locMsgs })
398+ | Object (dict {"type" : String (other )}) =>
399+ Unknown (` Unknown conversion result type "${other}"` , json )
400+ | _ =>
401+ throw (
402+ Failure (
403+ ` Failed to decode ConversionResult. ${__LOC__}. Could not decode \` ${json-> JSON.stringify}\` ` ,
404+ ),
405+ )
407406 }
408407 }
409408}
You can’t perform that action at this time.
0 commit comments