question

Steven Chen avatar image
2 Likes"
Steven Chen asked Phil BoBo edited

Use FlexScript to bring up custom exception

Hello,

Is there a command to can throw an exception manually?

I would like to terminate script executing if some condition fulfilled.

FlexSim 20.2.0
flexsim 20.2.0exception
· 1
5 |100000

Up to 12 attachments (including images) can be used with a maximum of 23.8 MiB each and 47.7 MiB total.

Benjamin W2 avatar image Benjamin W2 commented ·

Hi @steven.chen,

You could pretty easily "throw" an exception to the output console with a simple if statement:

if (your criteria is met)

{

print ("Your error message")

}

else

{

Run code

}


This will print to the output console, not the system console.

0 Likes 0 ·

1 Answer

·
Phil BoBo avatar image
1 Like"
Phil BoBo answered Phil BoBo edited

You don't need to throw an exception to terminate script execution. Just return a value.

if (someConditionFulfilled) {
    mpt("Error: some condition fulfilled\n");
    return 0;
}
5 |100000

Up to 12 attachments (including images) can be used with a maximum of 23.8 MiB each and 47.7 MiB total.

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 12 attachments (including images) can be used with a maximum of 23.8 MiB each and 47.7 MiB total.