Skip to main content
1-Visitor
December 10, 2024
Question

Writing Custom Thingworx Service 400 - 500 Level Error Return Code

  • December 10, 2024
  • 2 replies
  • 608 views

I want to do something like this - 

try{

if(someError)

   throw someErrorException()

}catch someErrorException{

result.message  = "someError happened"

}

 

Expected output in postman if the someError condition is true -

Status Code = 500 & response message = someError happened"

 

Instead of this, I am able to get it into status code 500 by forcefully writing erroneous code within the if statement but I am not able to set the error message. Its the standard error message which comes - "XYZ check scriptLog"

 

2 replies

18-Opal
December 10, 2024

Don't catch your exception. Instead of that simply try:

throw "Some error happened";

 / Constantine

16-Pearl
March 20, 2025

Hi @AD_10324110 
 

I wanted to follow up with you on your post to see if your question has been answered.
If so, please mark the appropriate reply as the Accepted Solution for the benefit of other members who may have the same question.
Of course, if you have more to share on your issue, please let the Community know so that we can continue to support.
 

Thanks,
Wenjing