details: https://code.openbravo.com/erp/devel/pi/rev/ed73bce3ae3b changeset: 34246:ed73bce3ae3b user: Carlos Aristu <carlos.aristu <at> openbravo.com> date: Thu Jun 28 12:23:51 2018 +0200 summary: fixes issue 38827: Some trigger error messages not shown nicely in PG10
Using capturing groups to retrieve just the DB message (it is surrounded by @) with the regular expression matcher. diffstat: src/org/openbravo/erpCommon/utility/ErrorTextParserPOSTGRE.java | 11 +++------ 1 files changed, 4 insertions(+), 7 deletions(-) diffs (21 lines): diff -r 9452a1f4fa8a -r ed73bce3ae3b src/org/openbravo/erpCommon/utility/ErrorTextParserPOSTGRE.java --- a/src/org/openbravo/erpCommon/utility/ErrorTextParserPOSTGRE.java Thu Jun 28 12:20:33 2018 +0200 +++ b/src/org/openbravo/erpCommon/utility/ErrorTextParserPOSTGRE.java Thu Jun 28 12:23:51 2018 +0200 @@ -146,13 +146,10 @@ */ // The regular expression . matches any character except a line terminator unless the DOTALL // flag is specified. - Pattern pattern = Pattern.compile(".*@.+@.*", Pattern.DOTALL); - if (pattern.matcher(myMessage).matches()) { - // if the message is a directly from postgres generated one, it has an 'ERROR :' prefix - // if it is passed via an AD_PINSTACE result, then the 'ERROR: ' has already been stripped - if ((myMessage.length() > 7) && (myMessage.startsWith("ERROR: "))) { - myMessage = myMessage.substring(7); - } + Pattern pattern = Pattern.compile("(.*)(@.+@)(.*)", Pattern.DOTALL); + Matcher matcher = pattern.matcher(myMessage); + if (matcher.matches()) { + myMessage = matcher.group(2); String translatedMsg = Utility.parseTranslation(getConnection(), getVars(), getLanguage(), myMessage); log4j.debug("translated message: {}", translatedMsg); ------------------------------------------------------------------------------ Check out the vibrant tech community on one of the world's most engaging tech sites, Slashdot.org! http://sdm.link/slashdot _______________________________________________ Openbravo-commits mailing list Openbravo-commits@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/openbravo-commits