web stats
Messages Error code or number - Mirth Community

Go Back   Mirth Community > Mirth Connect > Support

Thread Tools Display Modes
Old 09-28-2016, 01:12 AM
Bheema Bheema is offline
What's HL7?
Join Date: Aug 2016
Location: India
Posts: 4
Bheema is on a distinguished road
Send a message via Skype™ to Bheema
Default Messages Error code or number

Hi All,

Is there any way to get SQL error code in catch block( Like Java e.getErrorCode()) or how to get the LINE NUMBER if message got error(in below example LINE NUMBER: 820).

Transformer error
ERROR MESSAGE: Error evaluating transformer
com.mirth.connect.server.MirthJavascriptTransforme rException:
CONNECTOR: MSSQL Destination forWindows Install
815: params.add($('Current_Date'));
816: params.add($('Original_Msg'));
817: params.add($('Processed'));
818: params.add($('ProcParameterList'));
820: var dbConn = DatabaseConnectionFactory.createDatabaseConnection ($('jdbcDriver'),$('dbAddress'),$('dbLogin'),$('db Password'));
821: var RawMsgInsert = "INSERT INTO tblMsgs (MsgType, MsgDateTime, Msg, Processed, spMsg) VALUES (?,?,?,?,?)";
823: //channelMap.put("RawMsgInsert", RawMsgInsert);
DETAILS: Wrapped java.sql.SQLException: The syntax of the connection
Reply With Quote
Old 07-18-2019, 01:29 PM
bburkhart bburkhart is offline
What's HL7?
Join Date: Jun 2018
Posts: 3
bburkhart is on a distinguished road
Default Seems like "no"

I've been searching for an answer to this as well. You can capture some info if the error is thrown by Java, but that's not what you're asking nor what I'm looking for.

I have a block of code with a try catch, and the error handling obscures exactly where in the code the error is happening. It would be nice to be able to capture the line of the original error, rather than (or in addition to) the line where the error was thrown.
Reply With Quote
Old 07-18-2019, 06:29 PM
agermano agermano is offline
Mirth Guru
Join Date: Apr 2017
Location: Indiana, USA
Posts: 1,037
agermano is on a distinguished road

To answer the original question, I believe you can do
try {
    // ...
catch (e if e.javaException instanceof java.sql.SQLException) {
    var errorCode = e.javaException.getErrorCode();
For the second question, the easiest thing to do is not catch the exception in the first place. If you need to catch some exceptions, you can do a conditional catch as shown above (see also https://developer.mozilla.org/en-US/...ava_Exceptions) and let the rest of them pass through uncaught.

You might also consider multiple try/catch blocks so you have a better idea of what you are catching. You can also nest them if you need to wrap the entire thing in a try/finally without a catch.

try {
    // first thing
catch (e) {
    // handle thing somehow
    throw 'first thing threw an error';

// second thing

try {
    // third thing
catch {
    // handle thing somehow
    throw 'third thing threw an error';

try {
    // forth thing
finally {
    // don't catch anything, but still have finally block

Last edited by agermano; 07-18-2019 at 06:33 PM.
Reply With Quote

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 01:59 AM.

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