Permalink
Browse files

Preserve API errors thrown by metadata import failure.

Signed-off-by: John Else <john.else@citrix.com>
  • Loading branch information...
1 parent c55a240 commit 40c09a51efdc926839f456dcfca45bbacd0f2b30 @johnelse committed Apr 23, 2012
Showing with 6 additions and 2 deletions.
  1. +6 −2 ocaml/xapi/importexport.ml
View
8 ocaml/xapi/importexport.ml
@@ -273,9 +273,13 @@ let remote_metadata_export_import ~__context ~rpc ~session_id ~remote_address wh
raise (Api_errors.Server_error(Api_errors.task_cancelled, [ Ref.string_of remote_task ]))
| `pending ->
failwith "wait_for_task_completion failed; task is still pending"
- | `failure ->
+ | `failure -> begin
let error_info = Client.Task.get_error_info rpc session_id remote_task in
- failwith (Printf.sprintf "VM metadata import failed: %s" (String.concat " " error_info));
+ match error_info with
+ | code :: params when Hashtbl.mem Datamodel.errors code ->
+ raise (Api_errors.Server_error(code, params))
+ | _ -> failwith (Printf.sprintf "VM metadata import failed: %s" (String.concat " " error_info));
+ end
| `success ->
debug "Remote metadata import succeeded"
)

0 comments on commit 40c09a5

Please sign in to comment.