Skip to main content
Inspiring
September 10, 2009
Answered

Need more info about "AlertShow" violation

  • September 10, 2009
  • 1 reply
  • 4670 views

Hello,

First of all thanks for the great tool! It was really something we all missed.

I have a question related to the "AlertShow" violation. I got several such violations and the description says

"Do not call Alert.show directly.. You should not Alert.show() directly. If an error occurred in the system, you should probably use an ErrorManager to have a consistent way to manage those errors".

What exactly was meant by this violation? Could you, please provide more details why this violation pops up and how it is expected to be fixed.

Thank you!

This topic has been closed for replies.
Correct answer Xavier Agnetti

Hi,

Glad you liked the project.

So we often people using Alert.show whithout having a central ErrorManager class. Having such a class allows you to have a consistent way to deal with errors in your application.

Alert.show can be called from anywhere (view, model, commands, ...), whereas it is nothing else than a wrapped view.

I hope this helps.

Xavier

1 reply

Xavier AgnettiCorrect answer
Adobe Employee
September 11, 2009

Hi,

Glad you liked the project.

So we often people using Alert.show whithout having a central ErrorManager class. Having such a class allows you to have a consistent way to deal with errors in your application.

Alert.show can be called from anywhere (view, model, commands, ...), whereas it is nothing else than a wrapped view.

I hope this helps.

Xavier

Participating Frequently
April 13, 2011

PMD found these Alerts in my code too. I fail to see what is wrong with that.

What would an ErrorManager do more than report the error and wait for OK to know that the user saw it?

What to do after the error depends entirely on the place the error occurred, and

cannot be dealt with in a general way. Except maybe for logging it for later examination. Is that what you mean?

April 13, 2011

Using Alerts all over the place can have lots of drawbacks:

1. They are not good from a unit testing perspective, it's very hard to make assertions based on alerts. An Alert itself should not be used directly to specify errors. Otherwise, and highly likely, in a testrunner you'll end up having a ton of alerst one on top of the other without the ability to assert the expected behaviour

2. Normally applications have a centralized way to present messages or errors to the user. Allowing developers to simply allow the usage of Alerts will highly imply that when there's an error multiple alerts appear one on top of hte other.

3. Using or referencing an Alert from a model is not a "permitted" relationship. A PM or model shouldn't refernece the view, the view should reference the model (not hte other way arround).

does this make sense?