Error handling
Error handling in AL for Business Central covers error dialogs, try methods, collectible errors, actionable errors with Fix-it and Show-it actions, failure modeling, UX guidelines, and error telemetry. It answers how to raise, catch, collect, present and log errors.
- 16Learn pages
- 2subtopics
- 2videos
Path: Development > Programming in the AL language > Error handling · tier official · system development · narrative reviewed (checked by Opus)
Overview
This section explains how to deal with runtime errors in AL code. It starts with the general “AL error handling” page, which lists the main strategies: error dialogs, try methods, error collection, telemetry, the ErrorInfo data type and error message quality. The other pages go deeper on each strategy.
For writing errors, “Actionable errors” and “User experience guidelines for errors” describe how to use ErrorInfo with Fix-it and Show-it actions, and how to word and format messages. For catching and collecting errors, “Handling errors using try methods” and “Collecting Errors” cover the TryFunction attribute and the ErrorBehavior attribute with the error collection API. “Failure modeling and robust coding practices” gives the design principles behind defensive code.
For investigating errors, “Understanding the error dialog” explains the details users can copy, such as the AL call stack and the Application Insights session ID. The Error telemetry subtopic covers logging errors and feature usage to Application Insights. A subtopic with AL language reference pages for errors is also part of the section. Start with “AL error handling”, then pick the page that matches your task.
Key points
- Actionable errors use ErrorInfo objects with up to two actions: Fix-it actions that apply a recommended solution and Show-it actions that navigate the user to relevant information.
- Try methods use the TryFunction attribute, return a boolean, and let you read the error with GetLastErrorText and GetLastErrorObject. They have restrictions on database writes, and the page mentions runtime version 2.0.
- Collectible errors let a procedure gather several validation errors instead of stopping at the first. They use the ErrorBehavior attribute and an error collection API, and you can show the errors in the standard dialog or a custom UI.
- The error dialog has a Copy Details section with the AL call stack and the Application Insights session ID. The page mentions 2022 release wave 2 and 2023 release wave 1.
- Failure modeling rests on six principles: do not trust external code, consumers or the environment; offer graceful degradation; hide internal data structures; and assume improbable events will happen at scale.
- UX guidelines cover error message formatting, voice, validation errors, and best practices for error dialogs.
- Error telemetry covers logging to Application Insights, error message votes, permission errors (RT0031), and using the Telemetry AL module to log feature usage, errors and uptake.
Subtopics
- Error telemetry (4 pages)
- AL language reference (errors) (5 pages)
More Learn pages
- Actionable errors: Learn how to write AL code that returns error dialogs where users might unblock themselves.
- AL error handling: Deal with unexpected situations that occur when code is run in AL for Business Central.
- Collecting Errors: Learn how to write AL code that returns more than one error and presents users with more detailed error information.
- In the observatory: Page 700 “Error Messages”
- Failure modeling and robust coding practices: Describes how to reason over errors and handle them in code.
- Handling errors using try methods: Try methods in AL enable you to handle errors that occur in the application during code execution.
- Understanding the error dialog: Understand the different parts the error dialog to be able to help mitigate issues for users
- User experience guidelines for errors: Describes how to handle error dialogs in AL code.
Videos, posts and code changes
Linked by a Haiku matcher with a grounding quote from the item’s summary (link/topics.ts); machine-generated.
- #12117 [Job Queue] Clearer message and attempt number for runs interrupted by the platform (code change): “confusing ‘job has stopped’ error message with ‘run was interrupted’ message”
- #211 knowledge(error-handling): a bare [TryFunction] call propagates its error (code change): “bare calls to TryFunction procedures propagate errors rather than suppressing them”
- #99 Add lifecycle error and privacy knowledge (code change): “covering try-function semantics, upgrade phase data writes, install-versus-upgrade dispatch logic, ErrorInfo privacy”
- Why your Business Central job queue needs idempotent external effects when integrating external systems. (community post): “AL transaction rollback does not undo external API calls”
- 🔧 Transforming BC Error Handling with Smart Recommendations 📝 (community post): “Event Subscribers intercept Business Central errors, validate tag matches, and invoke the ErrorMessageFix interface”
- When “Errors” Don’t Stop the Process: A Hidden Risk in Business Central (community post): “ErrorBehavior::Collect allows code to continue after errors”
- How to Write Error Messages That Help (community post): “Error messages significantly impact user experience in enterprise software”
- BC Friday Tips #77 TestField Show Record Action (community post): “TestField automatically adds a Show Record button to error dialogs”
- Dynamics 365 Business Central: Regarding the default field name/table name in the error message thrown by Record.TestField Method (community post): “Record.TestField Method validates that a field is not empty”
- Business Central 2025 wave 2 (BC27): App version in “Copy error details”/”Share details via” (community post): “Error dialogs now display the extension version number alongside extension name”
- Dynamics 365 Business Central: View the last known error (community post): “Use GetLastErrorCode and GetLastErrorText methods to programmatically access error details”
- Dynamics 365 Business Central: GetLastErrorCode, GetLastErrorText and GetLastErrorCallStack Methods (community post): “GetLastErrorCode retrieves the error classification and is not translated to local language”
- 20261026 - The Rollback That Wasn’t Transaction & Error Handling (video): “transaction handling; error handling; rollback behavior; commit semantics; try-catch patterns”
- What’s New: Boost Your Productivity with Business Central (2024 release wave 1) (video): “Actions for platform-generated errors; Error sharing via Teams and email”
Source: Microsoft Learn (CC BY 4.0). Descriptions are Learn’s own.
What Learn documents here 8 of 16 Learn pages
- learnActionable errors2026-06-29
- learnAL error handling2024-03-01
- learnAnalyzing Error Message Vote Telemetry2026-11-17
- learnAnalyzing Error Method Trace Telemetry2026-11-17
- learnAnalyzing Permission Error Trace Telemetry2026-11-17
- learnCollectible errors API2023-12-25
- learnCollecting Errors2025-05-19
- learnDialog.Error(ErrorInfo) Method2026-10-01
Show 8 more
- learnDialog.Error(Text [, Any,...]) Method2026-10-01
- learnDialog.LogInternalError(Text, DataClassification, Verbosity) Method2026-10-01
- learnDialog.LogInternalError(Text, Text, DataClassification, Verbosity) Method2026-10-01
- learnFailure modeling and robust coding practices2024-01-11
- learnFeature telemetry2026-09-22
- learnHandling errors using try methods2025-06-18
- learnUnderstanding the error dialog2024-01-03
- learnUser experience guidelines for errors2025-01-21