Skip to content

Commit

Permalink
Move BadAsyncResult at the bottom of exception list
Browse files Browse the repository at this point in the history
Also update wording in `parseResult`

Signed-off-by: Danilo Del Busso <danilo.delbusso@cloud.com>
  • Loading branch information
danilo-delbusso committed May 9, 2024
1 parent 99f24b3 commit 36d9134
Showing 1 changed file with 14 additions and 13 deletions.
27 changes: 14 additions & 13 deletions ocaml/sdk-gen/java/templates/Types.mustache
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,19 @@ public class Types
}
{{/errors}}

public static class BadAsyncResult extends XenAPIException {
public final String result;
/**
* Create a new BadAsyncResult
*/
public BadAsyncResult(String result)
{
super(result);
this.result = result;
}
}

{{#types}}
/**
* Converts an {@link Object} to a {@link {{{name}}}} object.
Expand Down Expand Up @@ -215,24 +228,12 @@ public class Types

{{/generate_reference_task_result_func}}
{{/types}}

public static class BadAsyncResult extends XenAPIException
{
public final String result;
public BadAsyncResult(String result)
{
super(result);
this.result = result;
}
}

private static String parseResult(String result) throws BadAsyncResult
{
Pattern pattern = Pattern.compile("<value>(.*)</value>");
Matcher matcher = pattern.matcher(result);
if (!matcher.find() || matcher.groupCount() != 1) {
throw new Types.BadAsyncResult("Can't interpret: " + result);
throw new Types.BadAsyncResult("Can't parse: " + result);
}

return matcher.group(1);
Expand Down

0 comments on commit 36d9134

Please sign in to comment.