Think about encapsulation. Place them in an area where they are needed, and not in a wider range.
If something is used only within the user interface layer, do not expose it to other layers. But if it is used at two or three levels, then define it at the lower level (for example, if the user interface is in Business Logic, which is based on the database, then something that is used in BL and UI can simply be determined in BL). Or, if something is more or less global, move it to a third-party shared library.
Also, first try to minimize the need to use shared objects: for example, It is recommended (for good reason) to avoid custom exceptions. Most of them can usually be represented by an existing system exception with a bit of additional information (for example, InvalidOperationException with details in the message), which minimizes the need to handle the whole new class of exceptions everywhere - and courses that eliminate the need to decide where to define a custom exception type.
source share