Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. Design and Architecture
  4. Exception Handling Dilemma

Exception Handling Dilemma

Scheduled Pinned Locked Moved Design and Architecture
questiondatabasedebugging
4 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • B Offline
    B Offline
    Brady Kelly
    wrote on last edited by
    #1

    My debugger breaks for the below exception when trying to restore a database, because the database is in use. My question is, if I don't catch exceptions in my DatabaseHelper class, following what I believe to be good practice, then I should at least catch and publish the exception in clients of DatabaseHelper. However, these clients should know nothing of this FailedOperationException exception, so to catch it I would have to broaden my catch scope, which I believe is not good practice. What do I do? Microsoft.SqlServer.Management.Smo.SmoExceptionType.FailedOperationException

    P 1 Reply Last reply
    0
    • B Brady Kelly

      My debugger breaks for the below exception when trying to restore a database, because the database is in use. My question is, if I don't catch exceptions in my DatabaseHelper class, following what I believe to be good practice, then I should at least catch and publish the exception in clients of DatabaseHelper. However, these clients should know nothing of this FailedOperationException exception, so to catch it I would have to broaden my catch scope, which I believe is not good practice. What do I do? Microsoft.SqlServer.Management.Smo.SmoExceptionType.FailedOperationException

      P Offline
      P Offline
      Pete OHanlon
      wrote on last edited by
      #2

      You catch this in your database class. This is a specific database related problem - I would then throw this as a custom exception to the client applications, with details of this as the inner exception.

      Deja View - the feeling that you've seen this post before.

      My blog | My articles

      B 1 Reply Last reply
      0
      • P Pete OHanlon

        You catch this in your database class. This is a specific database related problem - I would then throw this as a custom exception to the client applications, with details of this as the inner exception.

        Deja View - the feeling that you've seen this post before.

        My blog | My articles

        B Offline
        B Offline
        Brady Kelly
        wrote on last edited by
        #3

        This is for a testing framework, so would you minimise custom exceptions and use one for multiple helper classes, or go with a tighter fit of one custom exception per helper class? Also, I use DatabaseHelper in SelectionHelper, so using only one custom exception reduces the complexity of Russian Doll type exceptions. In SelectionHelper I wrap CLR exceptions, and just re-throw custom exceptions.

        P 1 Reply Last reply
        0
        • B Brady Kelly

          This is for a testing framework, so would you minimise custom exceptions and use one for multiple helper classes, or go with a tighter fit of one custom exception per helper class? Also, I use DatabaseHelper in SelectionHelper, so using only one custom exception reduces the complexity of Russian Doll type exceptions. In SelectionHelper I wrap CLR exceptions, and just re-throw custom exceptions.

          P Offline
          P Offline
          Pete OHanlon
          wrote on last edited by
          #4

          We tend to use exceptions based on logical areas.

          Deja View - the feeling that you've seen this post before.

          My blog | My articles

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups