Components | All | New | MacOS | Windows | Linux | iOS | ||||
Examples | Mac & Win | Server | Client | Guides | Statistic | FMM | Blog | Deprecated | Old |
HadErrors
Queries error counter.
Component | Version | macOS | Windows | Linux | Server | iOS SDK |
Plugin | 12.2 | ✅ Yes | ✅ Yes | ✅ Yes | ✅ Yes | ✅ Yes |
Parameters
none
Result
Returns number or error.
Description
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.
Examples
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
- ErrorLog
- Files.Delete
- Files.FileExists
- FM.InsertRecord
- Folders.UserDocuments
- Path.AddPathComponent
- Text.ReadTextFile
Release notes
- Version 12.2
- Added ClearErrors and HadErrors functions.
Blog Entries
- MBS @ FMTraining.TV - The FileMaker MonkeyBread Plug-in Q&A
- MBS @ FMTraining.TV - Error Capturing with the MBS Plugin - FileMaker MBS Q&A
- FileMaker and MongoDB
- Top 10 from the MBS Plugin in 2022
- MBS FileMaker Plugin 12.3
- New error log functions for FileMaker
- MBS FileMaker Plugin 12.2
- MBS Plugin 12.2 for Claris FileMaker
- Transactions with SQL functions
- MBS FileMaker Plugin, version 12.2pr4
This function is free to use.
Created 28th April 2022, last changed 14th March 2024
