Skip to content

Commit

Permalink
Make IsNative always true for echo; rethrow on invalid argument rpc e…
Browse files Browse the repository at this point in the history
…xception when src and trg language are not the same for echo (#444)
  • Loading branch information
Enkidu93 authored Jul 29, 2024
1 parent f5b7620 commit b7b8b68
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -316,7 +316,7 @@ ServerCallContext context
)
{
return Task.FromResult(
new GetLanguageInfoResponse { InternalCode = request.Language + "_echo", IsNative = false, }
new GetLanguageInfoResponse { InternalCode = request.Language + "_echo", IsNative = true, }
);
}

Expand Down
12 changes: 12 additions & 0 deletions src/Serval/src/Serval.Translation/Services/EngineService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,18 @@ public override async Task<Engine> CreateAsync(Engine engine, CancellationToken
IsModelPersisted = createResponse.IsModelPersisted
};
}
catch (RpcException rpcex)
{
await Entities.DeleteAsync(engine, CancellationToken.None);
if (rpcex.StatusCode == StatusCode.InvalidArgument)
{
throw new InvalidOperationException(
$"Unable to create engine {engine.Id} because of an invalid argument: {rpcex.Status.Detail}",
rpcex
);
}
throw;
}
catch
{
await Entities.DeleteAsync(engine, CancellationToken.None);
Expand Down

0 comments on commit b7b8b68

Please sign in to comment.