---
title: "Global Error Handling"
url: "https://courses.osherove.com/courses/automating-all-the-things-with-finalbuilder/global-error-handling.md"
canonical: "https://courses.osherove.com/courses/automating-all-the-things-with-finalbuilder/global-error-handling/"
tags: []
author: "Roy Osherove"
description: "Lesson 11 of 18 in Automating All the Things with FinalBuilder (Flow Control & Error Handling), 4:46. Free video by Roy Osherove."
usage: "Licensed under CC BY 4.0 — reuse, quote and adapt with attribution (Roy Osherove, link to the original page)."
license: "https://creativecommons.org/licenses/by/4.0/"
---

# Global Error Handling

1. [Courses](https://courses.osherove.com/#courses)
2. [Automating All the Things with FinalBuilder](https://courses.osherove.com/courses/automating-all-the-things-with-finalbuilder/)
3. Flow Control & Error Handling

Lesson 11 of 18

Duration: 4:46 [Watch on YouTube](https://www.youtube.com/watch?v=jTy10D_Bz6I)

## In this lesson

Roy Osherove uses the on failure tab, the global error handler, to export the [FinalBuilder](https://osherove.com/blog/2005/3/12/cooltool-finalbuilder-30-the-ultimate-build-management-and-a.html "[CoolTool] FinalBuilder 3.0 - the ultimate build management and automation tool (osherove.com)") log to an HTML file in a logs folder when anything fails. The first run cannot export the log because the folder does not exist, so he adds a create directory action before the export, and he shows how a send email action can attach the log file.

## Transcript

689 words

[\[00:02\]](https://www.youtube.com/watch?v=jTy10D_Bz6I&t=2s) Let's talk about global error handling and standard error handling. So let's say that if at any point in time here we have an error, we'd like to get an email with a log file or something like this. So by default there's a global error handler. Wherever anything happens, you can go to on failure and here you can basically add a task. So one of the tasks you'd like to do is for example to say that there's a log file. We can export a log to a file that's the FinalBuilder log.

[\[00:32\]](https://www.youtube.com/watch?v=jTy10D_Bz6I&t=32s) So we can say let's create an output file in the FB project directory slash logs slash full dot log. It can be an HTML. Let's let's make it HTML actually. It could be text or XML. So let's make it a HTML and we can export from the root of the project. By default all included project will only export itself.

[\[01:04\]](https://www.youtube.com/watch?v=jTy10D_Bz6I&t=64s) If we have multiple projects we that we that we have invoked from within FinalBuilder we can export those logs as well. We can make it only include air actions but we don't have to. And by default I just like this. We can also just include a specific fragment or just the entire log or just logs from a specific action. And that's it. So, let's say that we go into main

[\[01:34\]](https://www.youtube.com/watch?v=jTy10D_Bz6I&t=94s) And we want to create some sort of failure. So, let's create a failure here in that we go like this. We give it a bad parameter. So now let me run this and see what happens and we definitely get errors here and we see that by default we got the on failure. Okay so this is very important on failure happened.

[\[02:05\]](https://www.youtube.com/watch?v=jTy10D_Bz6I&t=125s) If we go to the main action, you'll see that the script stopped at this stage. We got on failure and if we are lucky enough and we configured everything okay, we should have a logs directory. However, we do not and that might be a problem, right? So, let's try to see what the hell happened. Export log file error exporting cannot create the file.

[\[02:35\]](https://www.youtube.com/watch?v=jTy10D_Bz6I&t=155s) The system cannot find the path specified. So we don't have the path here. So we could try to create the path. For example, create let you see I'm searching here. Say create directory. We can create a directory called FB project directory slashblogs if one doesn't exist. And I can force a directory if one is not existing. So if I wanted to force it, I would say a /b C and I said force directories, it would create all the directories under C so that it can create this directory.

[\[03:13\]](https://www.youtube.com/watch?v=jTy10D_Bz6I&t=193s) But for now, we just have a single directory and that's the one. And let me move that up. So now even if the directory does not exist, before we export, we create this directory. it will not delete it if it already exists. So let me try to run this again and this time we see we have export and that's actually completed. So when we go down and we want to see the file that was created we can open the directory. Now if we double click this you will see under FP demo we have logs directory and then we have full.

[\[03:46\]](https://www.youtube.com/watch?v=jTy10D_Bz6I&t=226s) Let me double click this and now we see this interesting log file going on. We can actually open the description of each one and see what happened. And if we wanted to, we can even email stuff. So, we can let's look for the email. Send an email. So, you almost always have what you're looking for. You can say what's the SMTP host, sender, recipient, message, what to attach, and we can attach

[\[04:19\]](https://www.youtube.com/watch?v=jTy10D_Bz6I&t=259s) Specific log files. We can say FB project directory /logs slash full.html. And this is important. Add the plus here. Otherwise, it will not be written. Only stuff written here will actually be used. And if it's missing, you can just ignore it. Otherwise, you're going to get an error. So that's the global error handling so far.

## Related

### Also linked in this lesson

#### osherove.com

- [\[CoolTool\] FinalBuilder 3.0 - the ultimate build management and automation tool](https://osherove.com/blog/2005/3/12/cooltool-finalbuilder-30-the-ultimate-build-management-and-a.html)

[Previous lesson Reusable Action Lists and Action Groups](https://courses.osherove.com/courses/automating-all-the-things-with-finalbuilder/reusable-action-lists-and-action-groups/) [Next lesson Local Error Handling: Try-Catch-Finally Blocks](https://courses.osherove.com/courses/automating-all-the-things-with-finalbuilder/local-error-handling-try-catch-finally-blocks/)


---

## About the author

**Roy Osherove**: Senior Solutions Architect at AWS working on AI for production and AI-driven development; author of The Art of Unit Testing and Elastic Leadership, with about 20 years of consulting and training on unit testing, TDD, team leadership and continuous delivery.

### Sites

- [RobotPaper](https://robotpaper.ai/): This blog: AI patterns and anti-patterns, AI and coding agents, and engineering leadership.
- [osherove.com](https://osherove.com): Roy's personal site. Author of The Art of Unit Testing and Elastic Leadership; consulting and training on unit testing, TDD, team leadership and continuous delivery, plus about 20 years of blog posts.
- [The Art of Unit Testing](https://www.artofunittesting.com): The Art of Unit Testing, 3rd Edition (Manning): readable, maintainable, trustworthy unit tests, plus TDD workshops in C#, JavaScript, Java and Kotlin.
- [5whys.com](https://www.5whys.com): Roy's writing on software team leadership: self-organizing teams, surviving chaos, learning mode and the Elastic Leadership model.
- [Pipeline Driven](https://pipelinedriven.org): Continuous delivery and DevOps practices: build patterns, pipeline-friendly testing, DevOps metrics and enterprise DevOps.
- [Elastic Leadership](https://www.elasticleadership.com): Elastic Leadership, Roy's framework for software team leaders (survival, learning and self-organizing modes).

### Social

- X: https://x.com/royosherove
- LinkedIn: https://www.linkedin.com/in/osherove/

### Contact

- Contact form: https://forms.gle/jQSx5KoXvrVA1JCK7

### License

Licensed under CC BY 4.0 — reuse, quote and adapt with attribution (Roy Osherove, link to the original page). License: https://creativecommons.org/licenses/by/4.0/
