# Calling Project Library Script in a scheduled gateway event

**URL:** <https://forum.inductiveautomation.com/t/calling-project-library-script-in-a-scheduled-gateway-event/112143>\
**Category:** Ignition\
**Tags:** ignition81\
**Created:** [November 12, 2025, 11:03pm UTC](https://forum.inductiveautomation.com/t/calling-project-library-script-in-a-scheduled-gateway-event/112143 "2025-11-12T23:03:05Z")\
**Posts on this page:** 1\
**Showing post:** 4

<div class="post-metadata">

**Author:** ![ryan.white](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/ryan.white/32/73193_2.png) [@ryan.white](https://forum.inductiveautomation.com/u/ryan.white)\
**Post date:** [November 15, 2025, 7:45pm UTC](https://forum.inductiveautomation.com/t/calling-project-library-script-in-a-scheduled-gateway-event/112143/4 "2025-11-15T19:45:54Z")

</div>

Pictures are great for context but please also post copies of code as preformatted text. It helps to speed up the troubleshooting process by others, see [Wiki - how to post code on this forum](https://forum.inductiveautomation.com/t/wiki-how-to-post-code-on-this-forum/77831). You can edit your post to add it via the pencil icon in the bottom right.

Please also post the full error stack trace (if one exists) as preformatted text as well, the full trace will have important information to help troubleshoot.

Based on your existing logic and logging, I'd say the failure is somewhere in your `mainScript` function, likely in one of the other functions that you are calling. If you are touching a DB, you are likely getting a java db error which won't be caught as a python Exception.

Add

```python
except java.lang.Throwable as t:
    logger.warn("A java exception occured", t)

```

to your try block, this should catch any java errors.

Additionally, I would avoid having `import traceback` that late in the script (or in a function at all). Move the gateway script logic to a project library script and call it with a single line from the scheduled script. Import `traceback` at the top of the project library script outside of the function.

---

_[View the full topic](https://forum.inductiveautomation.com/t/calling-project-library-script-in-a-scheduled-gateway-event/112143)._
