Components | All | New | MacOS | Windows | Linux | iOS | ||||
Examples | Mac & Win | Server | Client | Guides | Statistic | FMM | Blog | Deprecated | Old |
AddToErrorLog
Adds log entry to current error log.
Component | Version | macOS | Windows | Linux | Server | iOS SDK |
Plugin | 12.3 | ✅ Yes | ✅ Yes | ✅ Yes | ✅ Yes | ✅ Yes |
Parameters
Parameter | Description | Example |
---|---|---|
JSON | The error as JSON. | "{\"error\": \"Test\"}" |
Result
Returns OK or error.
Description
Adds log entry to current error log.Please pass JSON to be added to the error log managed by the MBS Plugin.
You may use ClearErrors function to clear error log on start of a script.
Examples
Sample custom function to add FileMaker error to our Error Log:
// AddFileMakerErrorToLog(context) custom function
Let([
e = Get( LastError );
d = Get( LastErrorDetail );
r = MBS("AddToErrorLog";
JSONSetElement ( "{}" ;
[ "context" ; context; JSONString ] ;
[ "lastError" ; e; JSONNumber ] ;
[ "lastErrorMessage" ; d; JSONString ] ;
[ "scriptName" ; Get(ScriptName); JSONString ];
[ "fileName" ; Get(FileName); JSONString ];
[ "currentTimeStamp" ; Get(CurrentTimestamp); JSONString ]
))
]; e ≠ 0)
Catch various errors in MBS Plugin and in FileMaker:
Set Error Capture [ On ]
#
# start error logging
Set Variable [ $r ; Value: MBS("ClearErrors") ]
#
Loop
#
# cause some errors
Set Variable [ $r ; Value: MBS("test"; 1; "Hello") ]
Exit Loop If [ MBS("IsError") ]
#
Set Variable [ $r ; Value: MBS("DynaPDF.Print"; 1; "Hello") ]
Exit Loop If [ MBS("IsError") ]
#
# FileMaker error
Perform Script [ Specified: From list ; <unknown> ; Parameter: ]
Exit Loop If [ CheckError ]
#
# here we are done and no error happend
Exit Script [ Text Result: "Success" ]
End Loop
#
# now query error log
Set Variable [ $r ; Value: MBS("ErrorLog") ]
# and notice developer
Show Custom Dialog [ "Error Log" ; $r ]
CheckError custom function:
Let([
e = Get(LastError);
r = If( e ≠ 0; AddFileMakerErrorToLog("Found error"); "")
]; e ≠ 0)
See also
Release notes
- Version 12.3
- Added AddToErrorLog function to add custom log entries.
Blog Entries
- MBS @ FMTraining.TV - The FileMaker MonkeyBread Plug-in Q&A
- Top 10 from the MBS Plugin in 2022
- MBS FileMaker Plugin 12.3
- Neues MBS Plugin 12.3 für Claris FileMaker
- MBS Plugin 12.3 for Claris FileMaker
- MBS FileMaker Plugin, version 12.3pr5
- New error log functions for FileMaker
This function is free to use.
Created 23th June 2022, last changed 28th June 2024