# Decorating runAction functions in component Script actions?

**URL:** <https://forum.inductiveautomation.com/t/decorating-runaction-functions-in-component-script-actions/104978>\
**Category:** Ignition\
**Tags:** perspective\
**Created:** [April 11, 2025, 12:55am UTC](https://forum.inductiveautomation.com/t/decorating-runaction-functions-in-component-script-actions/104978 "2025-04-11T00:55:51Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![nminchin](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/nminchin/32/6911_2.png) [@nminchin](https://forum.inductiveautomation.com/u/nminchin)\
**Post date:** [April 11, 2025, 12:55am UTC](https://forum.inductiveautomation.com/t/decorating-runaction-functions-in-component-script-actions/104978/1 "2025-04-11T00:55:51Z")

</div>

Is it possible to decorate these `runAction` functions? I want to show any errors in the script to the user and maybe do other actions, but at the moment I just copy boiler plate code with try/except blocks, however I'd really like to globally define this in a script module as a decorator function to do what I want so that I can centrally manage it and modify it if I need.

Is this at all possible?

Most of the time I have the scripts I call defined within script modules, however if there's a typo or something preventing that function call from running, these will go silently by without the user knowing anything happened or that there was an error.

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/a/c/ace55047e49e2fc8b1eb5fe2c520a40bbc1bda92.png)

E.g.

```python
@shared.decorators.runActions
def runAction(self, event):
   sharred.prespective.sayHello() # typos in the module name prevents code from running, but won't be flagged without error handling

```

---

<div class="post-metadata">

**Author:** ![pturmel](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pturmel/32/3295_2.png) [@pturmel](https://forum.inductiveautomation.com/u/pturmel)\
**Post date:** [April 11, 2025, 11:48am UTC](https://forum.inductiveautomation.com/t/decorating-runaction-functions-in-component-script-actions/104978/2 "2025-04-11T11:48:20Z")

</div>

No. You should be using one-liners calling to the project library, and you can decorate those.

---

<div class="post-metadata">

**Author:** ![paul-griffith](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/paul-griffith/32/37249_2.png) [@paul-griffith](https://forum.inductiveautomation.com/u/paul-griffith)\
**Post date:** [April 11, 2025, 2:49pm UTC](https://forum.inductiveautomation.com/t/decorating-runaction-functions-in-component-script-actions/104978/3 "2025-04-11T14:49:50Z")

</div>

I mean, technically this would be possible under the hood, as far as I know. Would require some significant changes to the editor logic and the way these scripts are stored under the hood, which on its own makes it unpalatable, but not totally inconceivable.

In your example, though, you're just as likely to typo `shared.deccorators.runActions` as you are `sharred.perspective.sayHello` 🤷, so even above the implementation-wise reasons not to do it I'm not convinced _by this example_.

If you don't want the full 'ceremony' of a project library script, you could also write the business logic as a custom method, and decorate _that_ from `runAction`;

```python
def runAction(self, event)
    @shared.decorators.runActions
    self.sayHello()

```
