cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

How to handle exception in Mashup using customized widget

Highlighted
Pearl

How to handle exception in Mashup using customized widget

Hi , 

The bounded service in Mashup will popup the exception message raised from the ThingWorx javascript service , it's default behavior.   

 

I want to use a customized  message box to display the exception message ,  but how does the customized widget catch the exception of the ThingWorx service ? 

 

Regards,

Sean

7 REPLIES 7
Highlighted

Re: How to handle exception in Mashup using customized widget

Hi @seanccc.

 

Can you provide details of the use case?  What happens when the service runs successfully?  What are some of the error messages you need to display?  This may help us to provide a better example of how to meet your requirements.

 

Regards.

 

--Sharon

Highlighted

Re: How to handle exception in Mashup using customized widget

@slangley ,

The ThingWorx service can only set fix successful message which display in the mashup.  I want do display a customized message because: 

  • the service may has different kinds of return result and for each result the displayed message should be different.  This can be implemented via expression and popup mashup, but doing so for every service is very tedious. 
  • the customer don't like the default message box of the service, they want to change the font/color/background/size of the message box, so does for the error message box. 

So I want to know if there's a general way to catch the result of the service, whatever it's successful or failed. Then I can display the result in a customized widget(message box). 

 

Regards,

Sean

Highlighted

Re: How to handle exception in Mashup using customized widget

Sean, I believe the option of having a generic "Error Mashup" that you build once and reuse, is still the most flexible. You could reuse a EventRouter that has as inputs the results of the services, so you'd need just another expression that decides if the navigation would be displayed or not and the navigation.

If you're not inclined to do this, one of my previous colleagues, Gabriel Bucur, designed a CSS styling code for that, that you can take a look in the GitBackup.Main.Mashup from the GitBackupExtension. Look in the CustomCSS section and search for /* status message styled */
It's not that flexible though.
Highlighted

Re: How to handle exception in Mashup using customized widget

@seanccc Hello,

 

can be achieved it in many ways,

  • simplest way is to create one session parameter and define your baseType accordingly.
  • In each of your service, at the end update service status message to that session parameter using setGlobalSession services.
  • Create your custom message box and then bind session value to that message box. 
  • In all your mashup's after service execution event complete trigger this message box.

This way, you don't have to worry about any bindings and service output conversions or any other expressions.

 

Hope this works for you.

Highlighted

Re: How to handle exception in Mashup using customized widget

@abhiramk @VladimirRosu ,

Think you for your suggestions,  but they're still not general I think. 

 

Each service call in the mashup has to take care the of  result to do something to trigger the popup message.   But it should be done by only calling  ' throw new Error("This is an error"); '  in the javascript service.   This is actually the default behavior of ThingWorx, but I need to customize the default status message box(box size, text, position, modal popup) and won't introduce duplicate settings in mashup for each service. 

Highlighted

Re: How to handle exception in Mashup using customized widget

Hi Sean,

 

You can make your design to a better informative system. Irrespective of service status, show the message such as if it successful set success message in your service, else set error message to the session. 

In mashup, after each service execution event give it to your message box.

 

If you just want to show error message then set error message to the session in your service. In mashup you have to add validator whether to show message box or not.

Highlighted

Re: How to handle exception in Mashup using customized widget

Hi @seanccc.

 

If you feel your question has been answered, please mark the Accepted Solution for the benefit of others with the same question.

 

Thank you for your participation in our community!

 

Regards.

 

--Sharon

Announcements

Thingworx Navigate content has a new home! Click here to access the new Thingworx Navigate forum!