Click here to Skip to main content
15,892,537 members
Articles / Web Development / ASP.NET

Take MVC to the Next Level in .NET

Rate me:
Please Sign up or sign in to vote.
4.62/5 (11 votes)
30 Apr 2013GPL315 min read 73.2K   858   75  
How to quickly build reusable and flexible WPF, Silverlight, or ASP.NET applications with the powerful Xomega Framework using the best MVVM principles.
// Copyright (c) 2010-2012 Xomega.Net. All rights reserved.

using System.Runtime.Serialization;

namespace Xomega.Framework
{
    /// <summary>
    /// An error message that consists of an error code, a text message and the severity.
    /// Error messages are typically added to an error list and can be serialized
    /// to allow sending them in a service call.
    /// </summary>
    [DataContract]
    public class ErrorMessage
    {
        /// <summary>
        /// Default constructor to support deserialization.
        /// </summary>
        protected ErrorMessage() { }
        
        /// <summary>
        /// Constructs an error with a given error code and message.
        /// </summary>
        /// <param name="code">The error code.</param>
        /// <param name="message">The error message.</param>
        public ErrorMessage(string code, string message)
            : this(code, message, ErrorSeverity.Error)
        {
        }

        /// <summary>
        /// Constructs an error message with a given code, message and severity.
        /// </summary>
        /// <param name="code">The error message code.</param>
        /// <param name="message">The text message.</param>
        /// <param name="sev">The error message severity.</param>
        public ErrorMessage(string code, string message, ErrorSeverity sev)
        {
            this.Code = code;
            this.Message = message;
            this.Severity = sev;
        }

        /// <summary>
        /// Error code, which is an error identifier.
        /// </summary>
        [DataMember]
        public string Code { get; set; }

        /// <summary>
        /// Full error message text in the current language.
        /// </summary>
        [DataMember]
        public string Message { get; set; }

        /// <summary>
        /// Error severity, which may affect the execution flow.
        /// </summary>
        [DataMember]
        public ErrorSeverity Severity { get; set; }
    }

    /// <summary>
    /// Error severity possible values.
    /// </summary>
    public enum ErrorSeverity
    {
        /// <summary>
        /// A warning that may be displayed to the user for the confirmation before proceeding,
        /// if supported by the current execution context.
        /// </summary>
        Warning,

        /// <summary>
        /// An error, that will be displayed to the user with the other errors. It doesn't stop
        /// the execution flow, but prevents the operation from successfully completing.
        /// </summary>
        Error,

        /// <summary>
        /// A critical error, which stops the execution immediately and returns a fault to the user.
        /// </summary>
        Critical
    }
}

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The GNU General Public License (GPLv3)


Written By
Architect Xomega.Net
United States United States
Xomega Team is striving to increase productivity and development quality by utilizing Model Driven Development coupled with Code Generation and the best design practices for application development.
We provide MDD tools, code generators and frameworks for Visual Studio and .Net development.
Visit us at http://www.xomega.net
This is a Organisation

1 members

Comments and Discussions