Skip to main content
replaced http://stackoverflow.com/ with https://stackoverflow.com/
Source Link

From what I've seen, stereotype is usually used to represent the relationship to an exception.

a better approach would be to use UML’s stereotype notation with the keyword exception as the stereotype enclosed in guillemets, as in «exception».

Source: How can I represent an exception in UML?

This answer on Stack OverflowThis answer on Stack Overflow also suggests stereotypes, but uses <<throws>> instead. The author is confident that it's ok to use a stereotype which doesn't exist conventionally, and in this particular case, I agree with him.

As for the proper term, given that a stereotype can be a noun or a verb, both <<exception>> and <<throws>> seem equally correct. The proper terminology also depends on the language you use. For example in Python, you don't throw, but raise an error or an exception, so <<raises>> looks as the most appropriate one; unless your intention is to separate errors and exceptions, in which case <<exception>> and <<error>> may be more expressive.

Finally, Agile Modeling suggests (search for Figure 4) to embed the name of the exception like this:

+ findAllInstances(): Vector {exceptions=NetworkFailure, DatabaseError}

but IMO, while it's well suited for well-known exceptions used by the framework, it is too poor for custom exceptions you have created, because the relation is not visual enough.

From what I've seen, stereotype is usually used to represent the relationship to an exception.

a better approach would be to use UML’s stereotype notation with the keyword exception as the stereotype enclosed in guillemets, as in «exception».

Source: How can I represent an exception in UML?

This answer on Stack Overflow also suggests stereotypes, but uses <<throws>> instead. The author is confident that it's ok to use a stereotype which doesn't exist conventionally, and in this particular case, I agree with him.

As for the proper term, given that a stereotype can be a noun or a verb, both <<exception>> and <<throws>> seem equally correct. The proper terminology also depends on the language you use. For example in Python, you don't throw, but raise an error or an exception, so <<raises>> looks as the most appropriate one; unless your intention is to separate errors and exceptions, in which case <<exception>> and <<error>> may be more expressive.

Finally, Agile Modeling suggests (search for Figure 4) to embed the name of the exception like this:

+ findAllInstances(): Vector {exceptions=NetworkFailure, DatabaseError}

but IMO, while it's well suited for well-known exceptions used by the framework, it is too poor for custom exceptions you have created, because the relation is not visual enough.

From what I've seen, stereotype is usually used to represent the relationship to an exception.

a better approach would be to use UML’s stereotype notation with the keyword exception as the stereotype enclosed in guillemets, as in «exception».

Source: How can I represent an exception in UML?

This answer on Stack Overflow also suggests stereotypes, but uses <<throws>> instead. The author is confident that it's ok to use a stereotype which doesn't exist conventionally, and in this particular case, I agree with him.

As for the proper term, given that a stereotype can be a noun or a verb, both <<exception>> and <<throws>> seem equally correct. The proper terminology also depends on the language you use. For example in Python, you don't throw, but raise an error or an exception, so <<raises>> looks as the most appropriate one; unless your intention is to separate errors and exceptions, in which case <<exception>> and <<error>> may be more expressive.

Finally, Agile Modeling suggests (search for Figure 4) to embed the name of the exception like this:

+ findAllInstances(): Vector {exceptions=NetworkFailure, DatabaseError}

but IMO, while it's well suited for well-known exceptions used by the framework, it is too poor for custom exceptions you have created, because the relation is not visual enough.

Source Link
Arseni Mourzenko
  • 135.8k
  • 31
  • 350
  • 522

From what I've seen, stereotype is usually used to represent the relationship to an exception.

a better approach would be to use UML’s stereotype notation with the keyword exception as the stereotype enclosed in guillemets, as in «exception».

Source: How can I represent an exception in UML?

This answer on Stack Overflow also suggests stereotypes, but uses <<throws>> instead. The author is confident that it's ok to use a stereotype which doesn't exist conventionally, and in this particular case, I agree with him.

As for the proper term, given that a stereotype can be a noun or a verb, both <<exception>> and <<throws>> seem equally correct. The proper terminology also depends on the language you use. For example in Python, you don't throw, but raise an error or an exception, so <<raises>> looks as the most appropriate one; unless your intention is to separate errors and exceptions, in which case <<exception>> and <<error>> may be more expressive.

Finally, Agile Modeling suggests (search for Figure 4) to embed the name of the exception like this:

+ findAllInstances(): Vector {exceptions=NetworkFailure, DatabaseError}

but IMO, while it's well suited for well-known exceptions used by the framework, it is too poor for custom exceptions you have created, because the relation is not visual enough.