From cd653bc4960e70ec12b12862d71f6cfae261f218 Mon Sep 17 00:00:00 2001 From: Rafa de la Torre Date: Wed, 14 Dec 2016 10:35:44 +0100 Subject: [PATCH] Add diagnostics info to rest of cases #314 --- .../templates/25_exception_safe_private_functions.erb | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/client/renderer/templates/25_exception_safe_private_functions.erb b/client/renderer/templates/25_exception_safe_private_functions.erb index fa1ae6a..2dde980 100644 --- a/client/renderer/templates/25_exception_safe_private_functions.erb +++ b/client/renderer/templates/25_exception_safe_private_functions.erb @@ -27,7 +27,10 @@ BEGIN SELECT * FROM <%= DATASERVICES_CLIENT_SCHEMA %>._<%= name %>(<%= ['username', 'orgname'].concat(params).join(', ') %>); EXCEPTION WHEN OTHERS THEN - RAISE WARNING 'whatever'; + GET STACKED DIAGNOSTICS _returned_sqlstate = RETURNED_SQLSTATE, + _message_text = MESSAGE_TEXT, + _pg_exception_context = PG_EXCEPTION_CONTEXT; + RAISE WARNING USING ERRCODE = _returned_sqlstate, MESSAGE = _message_text, DETAIL = _pg_exception_context; END; <% elsif multi_field %> BEGIN @@ -47,7 +50,10 @@ BEGIN RETURN ret; EXCEPTION WHEN OTHERS THEN - RAISE WARNING 'whatever'; + GET STACKED DIAGNOSTICS _returned_sqlstate = RETURNED_SQLSTATE, + _message_text = MESSAGE_TEXT, + _pg_exception_context = PG_EXCEPTION_CONTEXT; + RAISE WARNING USING ERRCODE = _returned_sqlstate, MESSAGE = _message_text, DETAIL = _pg_exception_context; RETURN ret; END; <% end %>