Description of big and long may be good for some things, but definitely not for functions. Such functions are difficult to read, debug and get covered by tests. Usually when function looks too big it gets refactored in a way that logically independent blocks are moved into separate functions, this is called extraction.

Let's take a look on the some close to real life example of big function.

Let's make simple extraction here.

Now these functions are sharing too much variables. The good practice is to make these functions as decorator of state object.

So now we got n serial changes over an object by functions. Looks like we can make it nicer, putting all function into an array and executing them in a loop.

But what what with exceptions? Once upon a time I thought that this method may be represented as a chain like a promise. So why not really wrap it into a promise.

Now thats looks really nice, flexible and modular. Each part of the chain can be moved into separate file and covered by tests, comparing input and output states.