Components All New MacOS Windows Linux iOS
Examples Mac & Win Server Client Guides Statistic FMM Blog Deprecated Old


Queries error counter.

Component Version macOS Windows Linux Server iOS SDK
Plugin 12.2 ✅ Yes ✅ Yes ✅ Yes ✅ Yes ✅ Yes
MBS( "HadErrors" )




Returns number or error.


Queries error counter.
Call this on the end of a script to query how many errors happened.
You need to call ClearErrors function before on the start of the script to reset counter.
Use ErrorLog function to read the log.

The counter increases whenever a plugin function returns an error.
See also IsError function.

Errors are tracked per thread, so on a server each PSoS session has its own error log. And it includes errors from subscripts.


Log errors from FileMaker and MBS to a table:

# LogErrors in file HotKeys

# check for FileMaker errors
Set Variable [ $path ; Value: MBS("Path.AddPathComponent"; MBS("Folders.UserDocuments"); "ScriptErrors.log") ]
If [ MBS("Files.FileExists"; $path) ]
    # save the content of FileMaker's log file to the database table
    Set Variable [ $r ; Value: MBS("FM.InsertRecord"; Get(FileName); "Errors"; "Details"; MBS("Text.ReadTextFile"; $path; "UTF-8")) ]
    # make sure FileMaker makes a new file next time
    Set Error Logging [ Off Off ]
    # delete the file
    Set Variable [ $r ; Value: MBS("Files.Delete"; $path) ]
End If
# check for MBS errors on the way
If [ MBS("HadErrors") > 0 ]
    Set Variable [ $Log ; Value: MBS( "ErrorLog") ]
    # and write the JSON to a table
    Set Variable [ $r ; Value: MBS("FM.InsertRecord"; Get(FileName); "Errors"; "Details"; $Log) ]
End If

See also

Release notes

Blog Entries

This function is free to use.

Created 28th April 2022, last changed 14th March 2024

GetSystemUIModeOptions - Hash.CRC32