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

Community Tip - Want the oppurtunity to discuss enhancements to PTC products? Join a working group! X

How to handle exception in Mashup using customized widget

seanccc
17-Peridot

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
slangley
23-Emerald II
(To:seanccc)

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

seanccc
17-Peridot
(To:slangley)

@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

VladimirRosu
19-Tanzanite
(To:seanccc)

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.
abhiramk
13-Aquamarine
(To:seanccc)

@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.

seanccc
17-Peridot
(To:abhiramk)

@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. 

abhiramk
13-Aquamarine
(To:seanccc)

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.

slangley
23-Emerald II
(To:seanccc)

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


Top Tags