Blog de Francisco Velázquez

otro blog personal

Enumerados y Atributos

leave a comment »

Siempre me ha encantado la manera en que Gentle.NET maneja los errores, usando enumerados y atributos.

	/// <summary>
	/// This enumeration lists all common error conditions, their severity and a
	/// default error message.
	/// Unspecified errors or errors with no severity attribute are treated as critical.
	/// At this time almost all errors have been brainlessly classified as critical pending
	/// a review at some future time.
	/// </summary>
	public enum Error
		/// <summary>
		/// This error is used when no connection to the database server could be
		/// established. This is usually caused by errors in the connection
		/// string, but can also be due to network or database server problems.
		/// </summary>
		[Level( Severity.Critical ),
		 Message( "The database backend (provider {0}) could not be reached.\r\n" +
		          "Check the connection string: {1}" )]

		/// <summary>
		/// This error is used when an error in the use of Gentle was detected
		/// (e.g. invalid use of or missing custom attributes). No default message
		/// is provided for this error (if used via the Check class the first
		/// argument will be used as format string for remaining arguments).
		/// </summary>
		[Level( Severity.Error )]

Hoy he estado usando esta técnica en un proyecto.  Además he encontrado esta librería que también me ha servido de inspiración.

Written by fravelgue

September 8, 2009 at 4:30 pm

Posted in development

Tagged with , , , ,

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: