Build own AppleScript numerical error handling

I'm wanting to build an app for validating projects using custom error numbers I've defined similar to:

try ## do something on error number -2700 display dialog "Foobar" end try

with the help of JSON Helper defining the list as:

tell application "JSON Helper" set myJSON to make JSON from {-1232:"missing definition", -123231:"foo", -1232314:"bar" } return myJSON end tell

however I do not see a way to do this after referencing:

    <li>Error Numbers and Error Messages</li> <li>Working with Errors</li> </ul>

    other then using a bloated conditional like:

    try open for access file "MyFolder:AddressData" with write permission on error msg number n from f to t partial result p if n = -49 then -- File already open error display dialog "I'm sorry but the file is already open." else error msg number n from f to t partial result p end if end try

    After researching I was unable to populate anything other than "What techniques work to handle errors in AppleScript so I can place a dialog?" so is there a way in AppleScript I can write error handling similar to Error Numbers and Error Messages documentation?


    It's possible with a property list items.

    This script put a record in a new property list item

    Use the error number as string to get the value in the property list items

    set myRecord to {|-1232|:"missing definition", |-123231|:"foo", |-1232314|:"bar", |-49|:"I'm sorry but the file is already open.", |-43|:"This file wasn’t found."} tell application "System Events" to set myPlist to make new property list item with properties {kind:record, value:myRecord} try open for access file "MyFolder:AddressData" with write permission on error number n tell application "System Events" to set r to value of first property list item of myPlist whose its name is (n as text) display alert r end try <hr>

    Question of <strong>JMichaelTX</strong>

    Here's a script to save a property list items to a <strong>PLIST</strong> file (In the <strong>Preferences</strong> folder in this example).

    set plistPath to (path to preferences folder as string) & "errorsMsgs.plist" tell application "System Events" set myPlist to make new property list item with properties {kind:record, value:myRecord} make new property list file with properties {contents:myPlist, name:plistPath} end tell


  • How to add satellite assemblies to a project in Visual Studio
  • How do I see existing classes
  • How does Gradle's configurations hierarchy work?
  • How to overload the calling process of any function
  • Explicit instantiation declaration with extern
  • description for dll files
  • Why does non-const method hide const overload?
  • Index on every Foreign Key?
  • Hibernate manyToOne filter on base entity
  • Definition of server-class machine changed recently?
  • Ensure Ruby version in Nix Dev Environment when using latest version
  • Convert the http response body to JSON format using Unirest C#
  • Problem in defining object of a structure inside itself
  • How can I use C++ enum types like C#?
  • Why must we Forward Declare a class and include the corresponding header file in a header file
  • Problem obtaining entities with uniqueidentifier primary key
  • System.IO.Directory.GetFiles. No definition for GetFiles?
  • C++ reference variable across files
  • C++ boost::spirit parsing embedded languages
  • Blocks within NSOperation
  • Aspect advising other aspects
  • TypeScript DefinitelyTyped Ember.js d.ts doesn't compile
  • When querying against a view, a filtering clause in the view's definition is being ignored
  • How do I include screenshots of the full page in my serenity report (and not only of the viewport) u
  • Simple Factory with reflection C#
  • Extracting individual digits from a float
  • Copying rows in a database when rows have children
  • XNU incudes in Kext
  • Salesforce Different WSDL files and when to use
  • VSO Build — Response status code does not indicate success: 404 (Not Found)
  • DomPDF {PAGE_NUM} not on first page
  • Splitting given String into two variables - php
  • NetLogo BehaviorSpace - Measure runs using reporters
  • Is my CUDA kernel really runs on device or is being mistekenly executed by host in emulation?
  • Build own AppleScript numerical error handling
  • Is there a mandatory requirement to switch app.yaml?
  • Hits per day in Google Big Query
  • FormattedException instead of throw new Exception(string.Format(…)) in .NET
  • Linking SubReports Without LinkChild/LinkMaster
  • XCode 8, some methods disappeared ? ex: layoutAttributesClass() -> AnyClass