Enumerate Your Errors

Enumerate Your Errors

To keep a list of available error codes in your components, declare a private enumeration:

 Private Enum Errors	InvalidUserID = vbObjectError + 513	InvalidPassword	SearchNotFoundEnd Enum

Setting the first value sets the seed number for all subsequent items in the list, each one incrementing by one. (Microsoft recommends starting at “512 plus 1” above vbObjectError.)

Now you won’t have to remember error numbers throughout your code. Simply raise your errors like this:

 Err.Raise Errors.InvalidUserID, "Login", "Invalid UserID"

When you type the enumeration name Errors, VB pops up a list of available choices. Be careful, though, not to add new items in the middle of the list, because the value of all entries below the new item increases by one. This can cause the parent of the object to handle errors incorrectly because the error numbers will be different. You can avoid this by specifying exactly what value you want for each Enum, instead of relying on the default increment.

Share the Post:
data observability

Data Observability Explained

Data is the lifeblood of any successful business, as it is the driving force behind critical decision-making, insight generation, and strategic development. However, due to its intricate nature, ensuring the

Heading photo, Metadata.

What is Metadata?

What is metadata? Well, It’s an odd concept to wrap your head around. Metadata is essentially the secondary layer of data that tracks details about the “regular” data. The regular

XDR solutions

The Benefits of Using XDR Solutions

Cybercriminals constantly adapt their strategies, developing newer, more powerful, and intelligent ways to attack your network. Since security professionals must innovate as well, more conventional endpoint detection solutions have evolved