1

how would you declare this in a class diagram?

enum ErrorTitleType;

public class Users
{
    #region Custom Exception
    public class UsersException : Exception
    {
        public ErrorTitleType TitleTypeError { get; set; }
        public UsersException(string message, ErrorTitleType Typ ) : base(message)
        {
            TitleTypeError = Typ;
        }

    }
}

UPDATE: i was trying to have a customize Exception class for each logical class to seperate the errors with the UI class. Thats why i have 'Users' which is the locgial and 'UserException' to identify that its the exception class for error handling for 'Users'. i hope im not confusing anyone

k9nneo1191
  • 97
  • 8
  • https://en.wikipedia.org/wiki/Class_diagram#Generalization/Inheritance – Zohar Peled Jun 25 '19 at 07:38
  • In this example UsersException class inherited from Exception class as usual, what do you want to do? If you want to draw uml diagram look figure 4 on: https://developer.ibm.com/articles/the-class-diagram/ – Mert Akkanat Jun 25 '19 at 07:42
  • 3
    OP is trying to ask the relation between `Users` and `UsersException` – ilkerkaran Jun 25 '19 at 07:44
  • 1
    you can check out this answer, https://stackoverflow.com/questions/27146519/private-nested-java-class-in-uml-diagram – ilkerkaran Jun 25 '19 at 07:44
  • i was trying to have a customize Exception class for each logical class to seperate the errors with the UI class. Thats why i have 'Users' which is the locgial and 'UserException' to identify that its the exception class for error handling for 'Users'. i hope im not confusing anyone. – k9nneo1191 Jun 25 '19 at 07:55

2 Answers2

2

Declaring a class under a class

There is a dedicated notation in UML to indicate a class (here UsersException) is nested into an other (here Users) :

enter image description here

bruno
  • 32,421
  • 7
  • 25
  • 37
2

What you have coded is a nested class in UML as well. The class Users owns the class UsersException

In your model you would have something like

  • Package Model
    • Class Users
      • Class UsersException

In a diagram you can use the nesting connector to indicate the fact that the class Users owns the class UsersException, or you could enlarge the class Users and place the class UsersException in there
enter image description here

PS. Usually we name classes singular => User and UserException instead of Users and UsersException.

Geert Bellekens
  • 12,788
  • 2
  • 23
  • 50