From 9e152cca33b101b2951c4e14a5e7b35a79da5d81 Mon Sep 17 00:00:00 2001 From: Michal Lisiecki Date: Fri, 3 Jul 2015 15:55:15 +0200 Subject: [PATCH] Changed to throw Exception when MessageFactory cannot parse message. Change-Id: I12210d99cfec08173124b60eb59fb4212d889d53 --- src/main/java/com/solab/iso8583/MessageFactory.java | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/solab/iso8583/MessageFactory.java b/src/main/java/com/solab/iso8583/MessageFactory.java index a2a0746..f5b751d 100644 --- a/src/main/java/com/solab/iso8583/MessageFactory.java +++ b/src/main/java/com/solab/iso8583/MessageFactory.java @@ -413,7 +413,10 @@ public class MessageFactory { if (index == null) { log.error(String.format("ISO8583 MessageFactory has no parsing guide for message type %04x [%s]", type, new String(buf))); - return null; + throw new ParseException(String.format( + "ISO8583 MessageFactory has no parsing guide for message type %04x [%s]", + type, + new String(buf)), 0); } //First we check if the message contains fields not specified in the parsing template boolean abandon = false; @@ -424,7 +427,7 @@ public class MessageFactory { } } if (abandon) { - return m; + throw new ParseException("ISO8583 MessageFactory cannot parse fields", 0); } //Now we parse each field if (useBinary) {