Archived
forked from RDTKEditor/RDTKEditor
添加对 Core 的直接引用
This commit is contained in:
@@ -0,0 +1,47 @@
|
||||
using Newtonsoft.Json.Linq;
|
||||
namespace RhythmBase.Exceptions
|
||||
{
|
||||
/// <summary>
|
||||
/// Represents errors that occur during converting operations.
|
||||
/// </summary>
|
||||
public class ConvertingException : RhythmBaseException
|
||||
{
|
||||
#pragma warning disable IDE0052 // 删除未读的私有成员
|
||||
private readonly JToken? _convertingEvent;
|
||||
#pragma warning restore IDE0052 // 删除未读的私有成员
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="ConvertingException"/> class with a specified inner exception.
|
||||
/// </summary>
|
||||
/// <param name="innerException">The exception that is the cause of the current exception.</param>
|
||||
public ConvertingException(Exception innerException)
|
||||
: base("An exception was thrown on reading the level.", innerException) { }
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="ConvertingException"/> class with a specified error message.
|
||||
/// </summary>
|
||||
/// <param name="message">The message that describes the error.</param>
|
||||
public ConvertingException(string message)
|
||||
: base(string.Format("An exception was thrown on reading the event: {0}", message)) { }
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="ConvertingException"/> class with a specified event and inner exception.
|
||||
/// </summary>
|
||||
/// <param name="event">The event that caused the exception.</param>
|
||||
/// <param name="innerException">The exception that is the cause of the current exception.</param>
|
||||
public ConvertingException(JToken @event, Exception innerException)
|
||||
: base($"An exception was thrown on reading the event. \"{innerException}\"")
|
||||
{
|
||||
_convertingEvent = @event;
|
||||
}
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="ConvertingException"/> class with a specified event and inner exception.
|
||||
/// </summary>
|
||||
/// <param name="event">The event that caused the exception.</param>
|
||||
/// <param name="message">The exception that is the cause of the current exception.</param>
|
||||
public ConvertingException(JToken @event, string message)
|
||||
: base($"An exception was thrown on reading the event: {message}")
|
||||
{
|
||||
_convertingEvent = @event;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
namespace RhythmBase.Exceptions
|
||||
{
|
||||
/// <summary>
|
||||
/// Represents errors that occur during expression evaluation in the RhythmBase application.
|
||||
/// </summary>
|
||||
public class ExpressionException : RhythmBaseException
|
||||
{
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="ExpressionException"/> class.
|
||||
/// </summary>
|
||||
public ExpressionException()
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="ExpressionException"/> class with a specified error message.
|
||||
/// </summary>
|
||||
/// <param name="message">The message that describes the error.</param>
|
||||
public ExpressionException(string message) : base(message)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
namespace RhythmBase.Exceptions
|
||||
{
|
||||
/// <summary>
|
||||
/// Exception thrown when a file extension does not match the expected extension.
|
||||
/// </summary>
|
||||
public class FileExtensionMismatchException : SpriteException
|
||||
{
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="FileExtensionMismatchException"/> class.
|
||||
/// </summary>
|
||||
public FileExtensionMismatchException()
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="FileExtensionMismatchException"/> class with a specified error message.
|
||||
/// </summary>
|
||||
/// <param name="message">The message that describes the error.</param>
|
||||
public FileExtensionMismatchException(string message) : base(message)
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="FileExtensionMismatchException"/> class with a specified error message and a reference to the inner exception that is the cause of this exception.
|
||||
/// </summary>
|
||||
/// <param name="message">The message that describes the error.</param>
|
||||
/// <param name="innerException">The exception that is the cause of the current exception.</param>
|
||||
public FileExtensionMismatchException(string message, Exception innerException) : base(message, innerException)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
using RhythmBase.Events;
|
||||
namespace RhythmBase.Exceptions
|
||||
{
|
||||
/// <summary>
|
||||
/// Exception thrown when a beat is placed in an illegal position.
|
||||
/// </summary>
|
||||
public class IllegalBeatException(IBarBeginningEvent item) : RhythmBaseException
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets the error message that explains the reason for the exception.
|
||||
/// </summary>
|
||||
public override string Message
|
||||
{
|
||||
get
|
||||
{
|
||||
return string.Format("This beat is invalid, the event {0} only allows the beat to be at the beginning of the bar.", ((BaseEvent)Item).Type);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the event that caused the exception.
|
||||
/// </summary>
|
||||
public IBarBeginningEvent Item = item;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,92 @@
|
||||
using RhythmBase.Extensions;
|
||||
namespace RhythmBase.Exceptions
|
||||
{
|
||||
/// <summary>
|
||||
/// Exception thrown when an illegal event type is encountered.
|
||||
/// </summary>
|
||||
public class IllegalEventTypeException : RhythmBaseException
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets the error message that explains the reason for the exception.
|
||||
/// </summary>
|
||||
public override string Message
|
||||
{
|
||||
get
|
||||
{
|
||||
return string.Format("Illegal type: \"{0}\"{1}", IllegalTypeName, ExtraMessage.IsNullOrEmpty() ? "." : string.Format(", {0}", ExtraMessage));
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the extra message that provides additional information about the exception.
|
||||
/// </summary>
|
||||
public string ExtraMessage { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the name of the illegal type that caused the exception.
|
||||
/// </summary>
|
||||
public string IllegalTypeName { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="IllegalEventTypeException"/> class with the specified type.
|
||||
/// </summary>
|
||||
/// <param name="type">The illegal type that caused the exception.</param>
|
||||
public IllegalEventTypeException(Type type) : this(type, string.Empty)
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="IllegalEventTypeException"/> class with the specified type name.
|
||||
/// </summary>
|
||||
/// <param name="type">The name of the illegal type that caused the exception.</param>
|
||||
public IllegalEventTypeException(string type) : this(type, string.Empty)
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="IllegalEventTypeException"/> class with the specified type and extra message.
|
||||
/// </summary>
|
||||
/// <param name="type">The illegal type that caused the exception.</param>
|
||||
/// <param name="extraMessage">The extra message that provides additional information about the exception.</param>
|
||||
public IllegalEventTypeException(Type type, string extraMessage)
|
||||
{
|
||||
IllegalTypeName = type.Name;
|
||||
ExtraMessage = extraMessage;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="IllegalEventTypeException"/> class with the specified type name and extra message.
|
||||
/// </summary>
|
||||
/// <param name="type">The name of the illegal type that caused the exception.</param>
|
||||
/// <param name="extraMessage">The extra message that provides additional information about the exception.</param>
|
||||
public IllegalEventTypeException(string type, string extraMessage)
|
||||
{
|
||||
IllegalTypeName = type;
|
||||
ExtraMessage = extraMessage;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="IllegalEventTypeException"/> class with the specified type, extra message, and inner exception.
|
||||
/// </summary>
|
||||
/// <param name="type">The illegal type that caused the exception.</param>
|
||||
/// <param name="extraMessage">The extra message that provides additional information about the exception.</param>
|
||||
/// <param name="innerException">The exception that is the cause of the current exception.</param>
|
||||
public IllegalEventTypeException(Type type, string extraMessage, Exception innerException) : base("", innerException)
|
||||
{
|
||||
IllegalTypeName = type.Name;
|
||||
ExtraMessage = extraMessage;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="IllegalEventTypeException"/> class with the specified type name, extra message, and inner exception.
|
||||
/// </summary>
|
||||
/// <param name="type">The name of the illegal type that caused the exception.</param>
|
||||
/// <param name="extraMessage">The extra message that provides additional information about the exception.</param>
|
||||
/// <param name="innerException">The exception that is the cause of the current exception.</param>
|
||||
public IllegalEventTypeException(string type, string extraMessage, Exception innerException) : base("", innerException)
|
||||
{
|
||||
IllegalTypeName = type;
|
||||
ExtraMessage = extraMessage;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
using RhythmBase.Events;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace RhythmBase.Exceptions
|
||||
{
|
||||
/// <summary>
|
||||
/// Represents an exception that is thrown when an illegal row event type is encountered.
|
||||
/// </summary>
|
||||
public class IllegalRowEventTypeException : RhythmBaseException
|
||||
{
|
||||
public EventType EventType { get; }
|
||||
public RowType RowType { get; }
|
||||
public override string Message => $"{EventType} is not legal for {RowType} row.";
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="IllegalRowEventTypeException"/> class.
|
||||
/// </summary>
|
||||
public IllegalRowEventTypeException(EventType eventType, RowType rowType)
|
||||
{
|
||||
EventType = eventType;
|
||||
RowType = rowType;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
namespace RhythmBase.Exceptions
|
||||
{
|
||||
/// <summary>
|
||||
/// Exception thrown when an invalid RD beat is encountered.
|
||||
/// </summary>
|
||||
public class InvalidRDBeatException : RhythmBaseException
|
||||
{
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="InvalidRDBeatException"/> class.
|
||||
/// </summary>
|
||||
public InvalidRDBeatException()
|
||||
{
|
||||
Message = "The beat is invalid, possibly because the beat is not associated with the RDLevel.";
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the error message that explains the reason for the exception.
|
||||
/// </summary>
|
||||
public override string Message { get; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
namespace RhythmBase.Exceptions
|
||||
{
|
||||
/// <summary>
|
||||
/// Exception thrown when an attempt to overwrite a file is not allowed.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Initializes a new instance of the <see cref="OverwriteNotAllowedException"/> class with a specified error message and a reference to the inner exception that is the cause of this exception.
|
||||
/// </remarks>
|
||||
/// <param name="filepath">The file path that caused the exception.</param>
|
||||
/// <param name="referType">The type that caused the exception.</param>
|
||||
public class OverwriteNotAllowedException(string filepath, Type referType) : RhythmBaseException(filepath)
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets or sets the file path that caused the exception.
|
||||
/// </summary>
|
||||
public string FilePath { get; set; } = filepath;
|
||||
|
||||
/// <summary>
|
||||
/// Gets the message that describes the current exception.
|
||||
/// </summary>
|
||||
public override string Message => string.Format("Cannot save file '{0}' because overwriting is disabled by the settings and a file with the same name already exists.\r\nTo correct this, change the path or filename or set the OverWrite property of {1} to false.", FilePath, _referType.Name);
|
||||
|
||||
private readonly Type _referType = referType;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
namespace RhythmBase.Exceptions
|
||||
{
|
||||
/// <summary>
|
||||
/// Represents errors that occur during application execution in the RhythmBase application.
|
||||
/// </summary>
|
||||
public class RhythmBaseException : Exception
|
||||
{
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="RhythmBaseException"/> class.
|
||||
/// </summary>
|
||||
public RhythmBaseException()
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="RhythmBaseException"/> class with a specified error message.
|
||||
/// </summary>
|
||||
/// <param name="message">The message that describes the error.</param>
|
||||
public RhythmBaseException(string message) : base(message)
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="RhythmBaseException"/> class with a specified error message and a reference to the inner exception that is the cause of this exception.
|
||||
/// </summary>
|
||||
/// <param name="message">The message that describes the error.</param>
|
||||
/// <param name="innerException">The exception that is the cause of the current exception, or a null reference if no inner exception is specified.</param>
|
||||
public RhythmBaseException(string message, Exception innerException) : base(message, innerException)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
namespace RhythmBase.Exceptions
|
||||
{
|
||||
/// <summary>
|
||||
/// Represents errors that occur during sprite operations.
|
||||
/// </summary>
|
||||
public class SpriteException : Exception
|
||||
{
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="SpriteException"/> class.
|
||||
/// </summary>
|
||||
public SpriteException()
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="SpriteException"/> class with a specified error message.
|
||||
/// </summary>
|
||||
/// <param name="message">The message that describes the error.</param>
|
||||
public SpriteException(string message) : base(message)
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="SpriteException"/> class with a specified error message and a reference to the inner exception that is the cause of this exception.
|
||||
/// </summary>
|
||||
/// <param name="message">The message that describes the error.</param>
|
||||
/// <param name="innerException">The exception that is the cause of the current exception, or a null reference if no inner exception is specified.</param>
|
||||
public SpriteException(string message, Exception innerException) : base(message, innerException)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
namespace RhythmBase.Exceptions
|
||||
{
|
||||
/// <summary>
|
||||
/// Exception thrown when a type is not supported.
|
||||
/// </summary>
|
||||
[Serializable]
|
||||
internal class TypeNotSupportedException : Exception
|
||||
{
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="TypeNotSupportedException"/> class.
|
||||
/// </summary>
|
||||
public TypeNotSupportedException()
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="TypeNotSupportedException"/> class with a specified error message.
|
||||
/// </summary>
|
||||
/// <param name="message">The message that describes the error.</param>
|
||||
public TypeNotSupportedException(string? message) : base(message)
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="TypeNotSupportedException"/> class with a specified error message and a reference to the inner exception that is the cause of this exception.
|
||||
/// </summary>
|
||||
/// <param name="message">The message that describes the error.</param>
|
||||
/// <param name="innerException">The exception that is the cause of the current exception.</param>
|
||||
public TypeNotSupportedException(string? message, Exception? innerException) : base(message, innerException)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
using RhythmBase.Events;
|
||||
namespace RhythmBase.Exceptions
|
||||
{
|
||||
/// <summary>
|
||||
/// Exception thrown when an event is unreadable.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Initializes a new instance of the <see cref="UnreadableEventException"/> class with a specified error message and the unreadable event item.
|
||||
/// </remarks>
|
||||
/// <param name="message">The message that describes the error.</param>
|
||||
/// <param name="item">The unreadable event item.</param>
|
||||
public class UnreadableEventException(string message, IBaseEvent item) : RhythmBaseException(message)
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets the unreadable event item.
|
||||
/// </summary>
|
||||
public IBaseEvent Item { get; } = item;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
namespace RhythmBase.Exceptions
|
||||
{
|
||||
/// <summary>
|
||||
/// Exception thrown when the version is too low.
|
||||
/// </summary>
|
||||
public class VersionTooLowException : RhythmBaseException
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets the error message.
|
||||
/// </summary>
|
||||
public override string Message { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the level version that caused the exception.
|
||||
/// </summary>
|
||||
public int LevelVersion;
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="VersionTooLowException"/> class with the specified version.
|
||||
/// </summary>
|
||||
/// <param name="version">The version that is too low.</param>
|
||||
public VersionTooLowException(int version)
|
||||
{
|
||||
Message = string.Format("Might not support. The version {0} is too low. Save this level with the latest version of the game to update the level version.", LevelVersion);
|
||||
LevelVersion = version;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="VersionTooLowException"/> class with the specified version and inner exception.
|
||||
/// </summary>
|
||||
/// <param name="version">The version that is too low.</param>
|
||||
/// <param name="innerException">The exception that is the cause of the current exception.</param>
|
||||
public VersionTooLowException(int version, Exception innerException) : base(string.Empty, innerException)
|
||||
{
|
||||
Message = string.Format("Might not support. The version {0} is too low. Save this level with the latest version of the game to update the level version.", version);
|
||||
LevelVersion = version;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user