<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Bharani Vivek on Medium]]></title>
        <description><![CDATA[Stories by Bharani Vivek on Medium]]></description>
        <link>https://medium.com/@bharanivivek?source=rss-175812ad2521------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*dmbNkD5D-u45r44go_cf0g.png</url>
            <title>Stories by Bharani Vivek on Medium</title>
            <link>https://medium.com/@bharanivivek?source=rss-175812ad2521------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Fri, 20 Nov 2026 01:59:59 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@bharanivivek/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[My Standard Error-Handling Pattern in FileMaker Scripts]]></title>
            <link>https://medium.com/@bharanivivek/my-standard-error-handling-pattern-in-filemaker-scripts-0e714205f133?source=rss-175812ad2521------2</link>
            <guid isPermaLink="false">https://medium.com/p/0e714205f133</guid>
            <dc:creator><![CDATA[Bharani Vivek]]></dc:creator>
            <pubDate>Tue, 10 Feb 2026 17:36:14 GMT</pubDate>
            <atom:updated>2026-02-10T17:43:24.133Z</atom:updated>
            <content:encoded><![CDATA[<p>As a FileMaker developer gains experience, one thing becomes very clear:</p><blockquote><strong><em>Most real-world bugs are not logic bugs — they are unhandled errors.</em></strong></blockquote><p>Missing records, locked files, network drops, permission issues — these happen daily in production systems.</p><p>Over time, I stopped writing scripts that <em>assume success</em> and started writing scripts that <strong>expect failure</strong>.</p><p>This post explains the <strong>standard error-handling pattern</strong> I follow in almost every professional FileMaker solution.</p><h3>1️. First Rule: Never Trust Script Steps</h3><p>Many scripts look like this:</p><pre>Go to Layout [ Invoice ]<br>New Record<br>Set Field [ Invoice::Date ; Get ( CurrentDate ) ]<br>Commit Records</pre><p>This script <em>assumes</em>:</p><ul><li>Layout exists</li><li>User has access</li><li>Record creation succeeds</li><li>Commit works</li></ul><p>In production, these assumptions fail.</p><p>So the first mindset shift:</p><blockquote><strong><em>Every critical script step can fail.</em></strong></blockquote><h3>2️. My Core Pattern (High Level)</h3><p>Almost all my scripts follow this structure:</p><ol><li>Preparation</li><li>Action</li><li>Validation</li><li>Error capture</li><li>User-safe message</li><li>Clean exit</li></ol><p>This keeps scripts predictable and debuggable.</p><h3>3️. Always Start with Controlled Environment</h3><p>At the top of most scripts:</p><pre>Set Error Capture [ On ]<br>Allow User Abort [ Off ]</pre><p>Why?</p><ul><li>Prevent FileMaker dialogs from interrupting logic</li><li>Keep error handling centralized</li></ul><p>This alone removes a lot of randomness.</p><h3>4️. Capture Errors Immediately</h3><p>A common mistake is checking Get ( LastError ) too late.</p><p>I follow this rule:</p><blockquote><strong><em>Check errors immediately after the step that can fail.</em></strong></blockquote><p>Example:</p><pre>New Record/Request<br>Set Variable [ $error ; Get ( LastError ) ]</pre><p>Why?</p><ul><li>Another step can overwrite the error</li><li>Debugging becomes unreliable</li></ul><h3>5️.Use Variables, Not Dialogs</h3><p>Instead of showing dialogs everywhere, I store errors first:</p><pre>Set Variable [ $hasError ; $error ≠ 0 ]</pre><p>Benefits:</p><ul><li>Script flow remains clean</li><li>UI decisions handled later</li><li>Easier to log errors</li></ul><h3>6️. Centralize Error Messages</h3><p>I avoid hardcoding messages inside scripts.</p><p>Instead, I use:</p><ul><li>Custom Function: GetErrorMessage ( errorCode )</li><li>Or an Error table</li></ul><p>Example:</p><pre>Set Variable [ $msg ; GetErrorMessage ( $error ) ]</pre><p>Why?</p><ul><li>Consistent messaging</li><li>Easy to update</li><li>User-friendly language</li></ul><h3>7️.Fail Gracefully, Not Loudly</h3><p>Bad error handling:</p><ul><li>Technical messages</li><li>Sudden script stop</li><li>Confusing alerts</li></ul><p>My rule:</p><blockquote><strong><em>Users should know what to do next, not what went wrong internally.</em></strong></blockquote><p>Example message:</p><blockquote><em>“This invoice could not be saved. Please try again or contact support.”</em></blockquote><h3>8️. Log Errors for Developers, Not Users</h3><p>In professional systems, silent logging is critical.</p><p>I usually log:</p><ul><li>Script name</li><li>Error code</li><li>User</li><li>Timestamp</li><li>Context (Invoice ID, Record ID, etc.)</li></ul><p>This helps fix issues <strong>without disturbing users</strong>.</p><h3>9. One Exit Point</h3><p>I prefer scripts with:</p><ul><li>One clean exit</li><li>Controlled rollback if needed</li></ul><pre>If [ $hasError ]<br>   Show Custom Dialog [ &quot;Error&quot; ; $errorMsg ]<br>Else<br>   Show Custom Dialog [ &quot;Success&quot; ; &quot;Invoice created successfully.&quot; ]<br>End If<br><br>Exit Script [ Result: not $hasError ]</pre><p>This avoids:</p><ul><li>Half-created records</li><li>Inconsistent states</li></ul><h3>10.Why This Pattern Works</h3><p>This approach:</p><ul><li>Scales well</li><li>Reduces production bugs</li><li>Makes maintenance easier</li><li>Builds client trust</li></ul><p>Clients may not see error-handling code,</p><blockquote><em>but they feel its absence immediately.</em></blockquote><h3>Final Thought</h3><p>Junior developers write scripts that work.</p><p>Experienced FileMaker developers write scripts that <strong>fail safely</strong>.</p><p>If your solution runs smoothly even when things go wrong,</p><blockquote><em>that’s professional engineering.</em></blockquote><p><em>Written by a FileMaker developer who believes stability matters more than clever scripts.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=0e714205f133" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>