web stats
Channel Errors - Mirth Community

Go Back   Mirth Community > Mirth Connect > Support

Reply
 
Thread Tools Display Modes
  #1  
Old 05-08-2014, 07:05 AM
skekasaurus skekasaurus is offline
OBX.3 Kenobi
 
Join Date: Dec 2013
Posts: 145
skekasaurus is on a distinguished road
Default Channel Errors

I'm implementing some error handling for a channel but not entirely sure where would be the best place to handle it...

I have a channel that directs messages to other channels as a channel writer, and I have a particular channel as a channel reader with a destination that then sends those messages to a web service.

What I'm looking to do is if there is an error with the destinations, say the web service is down and couldn't connect to it, I would like to capture a copy of the original hl7 message. Currently, if there's any problems with the destinations the message gets lost (as far as I can tell).

I can already handle error responses that come back as soap xml, looking to handle errors thrown by Mirth when trying to process a message.

I did a bit of looking around and I came across two potential ways of doing this...setting up an error filter or handling the error in the postprocessor. Also, I saw a "Response Object" mentioned but not sure how to work with the object. Is there documentation on that somewhere?

Could anyone suggest the best way to go about what I'm trying to accomplish? I'm currently working with version 2.2.

Last edited by skekasaurus; 05-08-2014 at 08:07 AM.
Reply With Quote
  #2  
Old 05-20-2014, 06:05 AM
narupley's Avatar
narupley narupley is online now
Mirth Employee
 
Join Date: Oct 2010
Posts: 7,126
narupley is on a distinguished road
Default

Yes, the best place to do that is the postprocessor. You can grab the responses from destinations in the response map. For example, "responseMap.get('Destination 1')". That will return a Response object, and you can call getStatus() or getMessage() on it to retrieve the status or response payload (if any). In the postprocessor you can call "messageObject.getRawData()" to retrieve the original source raw message.
__________________
Step 1: JAVA CACHE...DID YOU CLEAR ...wait, ding dong the witch is dead?

Nicholas Rupley
Work: 949-237-6069
Always include what Mirth Connect version you're working with. Also include (if applicable) the code you're using and full stacktraces for errors (use CODE tags). Posting your entire channel is helpful as well; make sure to scrub any PHI/passwords first.


- How do I foo?
- You just bar.
Reply With Quote
  #3  
Old 07-29-2014, 10:47 AM
skekasaurus skekasaurus is offline
OBX.3 Kenobi
 
Join Date: Dec 2013
Posts: 145
skekasaurus is on a distinguished road
Default

Somewhat related to this, but now that I'm in 3.0 and can now use a response transformer, how am I able to capture the errors that may occur should the javascript break?

For exception errors that occur in a destination's transformer, in the postprocessor I'm able to get the status using:

Code:
responseMap.get('destination 1').getStatus();
But when I throw an exception in the response transformer, I get:

Code:
TypeError: Cannot call method "getStatus" of null
Reply With Quote
  #4  
Old 07-29-2014, 10:53 AM
narupley's Avatar
narupley narupley is online now
Mirth Employee
 
Join Date: Oct 2010
Posts: 7,126
narupley is on a distinguished road
Default

Yes that makes sense. Since an error occurred in the response transformer, no response entry will exist for that destination in the response map.

You should not be throwing an error manually in the response transformer. Just set the status to ERROR instead. There are templates in the References tab already for that.
__________________
Step 1: JAVA CACHE...DID YOU CLEAR ...wait, ding dong the witch is dead?

Nicholas Rupley
Work: 949-237-6069
Always include what Mirth Connect version you're working with. Also include (if applicable) the code you're using and full stacktraces for errors (use CODE tags). Posting your entire channel is helpful as well; make sure to scrub any PHI/passwords first.


- How do I foo?
- You just bar.
Reply With Quote
  #5  
Old 07-29-2014, 10:58 AM
skekasaurus skekasaurus is offline
OBX.3 Kenobi
 
Join Date: Dec 2013
Posts: 145
skekasaurus is on a distinguished road
Default

Quote:
Originally Posted by narupley View Post
Yes that makes sense. Since an error occurred in the response transformer, no response entry will exist for that destination in the response map.

You should not be throwing an error manually in the response transformer. Just set the status to ERROR instead. There are templates in the References tab already for that.
Well I won't normally be throwing errors manually, I wanted to test what would happen if something do go awry. In the response transformer I'll be sending off emails based on the response I get back from sending to a web service. So should the code that parses the SOAP envelope, or the sending of the HTML email not work, I would like some way for someone to be aware of the current error.
Reply With Quote
  #6  
Old 07-29-2014, 11:00 AM
narupley's Avatar
narupley narupley is online now
Mirth Employee
 
Join Date: Oct 2010
Posts: 7,126
narupley is on a distinguished road
Default

Quote:
Originally Posted by skekasaurus View Post
Well I won't normally be throwing errors manually, I wanted to test what would happen if something do go awry. In the response transformer I'll be sending off emails based on the response I get back from sending to a web service. So should the code that parses the SOAP envelope, or the sending of the HTML email not work, I would like some way for someone to be aware of the current error.
In that case, a good course of action would be to wrap your code in a try..catch, and in the catch block you can manually set the response status to ERROR, or modify the response status message or error content itself.
__________________
Step 1: JAVA CACHE...DID YOU CLEAR ...wait, ding dong the witch is dead?

Nicholas Rupley
Work: 949-237-6069
Always include what Mirth Connect version you're working with. Also include (if applicable) the code you're using and full stacktraces for errors (use CODE tags). Posting your entire channel is helpful as well; make sure to scrub any PHI/passwords first.


- How do I foo?
- You just bar.
Reply With Quote
  #7  
Old 07-29-2014, 11:05 AM
skekasaurus skekasaurus is offline
OBX.3 Kenobi
 
Join Date: Dec 2013
Posts: 145
skekasaurus is on a distinguished road
Default

Gotcha!!! Thanks Nick, always appreciate your help.
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -8. The time now is 04:53 PM.


Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2020, vBulletin Solutions, Inc.
Mirth Corporation