Exemplo n.º 1
0
        internal static string GetMessage(string worldName, WorldOpExceptionCode code)
        {
            if (worldName != null)
            {
                switch (code)
                {
                case WorldOpExceptionCode.CannotDoThatToMainWorld:
                    return("This operation cannot be done on the main world (" +
                           worldName + "). Assign a new main world and try again.");

                case WorldOpExceptionCode.DuplicateWorldName:
                    return("A world with this name (\"" + worldName + "\") already exists.");

                case WorldOpExceptionCode.InvalidWorldName:
                    return("World name \"" + worldName + "\" is invalid. " +
                           "Expected an alphanumeric name between 1 and 16 characters long.");

                case WorldOpExceptionCode.MapLoadError:
                    return("Failed to load the map file for world \"" + worldName + "\".");

                case WorldOpExceptionCode.MapMoveError:
                    return("Failed to rename/move the map file for world \"" + worldName + "\".");

                case WorldOpExceptionCode.MapNotFound:
                    return("Could not find the map file for world \"" + worldName + "\".");

                case WorldOpExceptionCode.MapPathError:
                    return("Map file path is not valid for world \"" + worldName + "\".");

                case WorldOpExceptionCode.MapSaveError:
                    return("Failed to save the map file for world \"" + worldName + "\".");

                case WorldOpExceptionCode.NoChangeNeeded:
                    return("No change needed for world \"" + worldName + "\".");

                case WorldOpExceptionCode.Cancelled:
                    return("Operation for world \"" + worldName + "\" was cancelled by a plugin.");

                case WorldOpExceptionCode.SecurityError:
                    return("You are not allowed to do this operation to world \"" + worldName + "\".");

                case WorldOpExceptionCode.Unexpected:
                    return("Unexpected problem occurred with world \"" + worldName + "\".");

                case WorldOpExceptionCode.WorldNotFound:
                    return("No world found with the name \"" + worldName + "\".");

                default:
                    return("Unexpected error occurred while working on world \"" + worldName + "\"");
                }
            }
            else
            {
                switch (code)
                {
                case WorldOpExceptionCode.CannotDoThatToMainWorld:
                    return("This operation cannot be done on the main world. " +
                           "Assign a new main world and try again.");

                case WorldOpExceptionCode.DuplicateWorldName:
                    return("A world with this name already exists.");

                case WorldOpExceptionCode.InvalidWorldName:
                    return("Given world name is invalid. " +
                           "Expected an alphanumeric name between 1 and 16 characters long.");

                case WorldOpExceptionCode.MapLoadError:
                    return("Failed to load the map file.");

                case WorldOpExceptionCode.MapMoveError:
                    return("Failed to rename/move the map file.");

                case WorldOpExceptionCode.MapNotFound:
                    return("Could not find the map file.");

                case WorldOpExceptionCode.MapPathError:
                    return("Map file path is not valid.");

                case WorldOpExceptionCode.MapSaveError:
                    return("Failed to save the map file.");

                case WorldOpExceptionCode.NoChangeNeeded:
                    return("No change needed.");

                case WorldOpExceptionCode.Cancelled:
                    return("Operation cancelled by a plugin.");

                case WorldOpExceptionCode.SecurityError:
                    return("You are not allowed to do this operation.");

                case WorldOpExceptionCode.WorldNotFound:
                    return("Specified world was not found.");

                default:
                    return("Unexpected error occurred.");
                }
            }
        }
Exemplo n.º 2
0
 public WorldOpException(string worldName, WorldOpExceptionCode errorCode, Exception innerException)
     : base(GetMessage(worldName, errorCode), innerException)
 {
     ErrorCode = errorCode;
 }
Exemplo n.º 3
0
 public WorldOpException(WorldOpExceptionCode errorCode, string message, Exception innerException)
     : base(message, innerException)
 {
     ErrorCode = errorCode;
 }
Exemplo n.º 4
0
        public static string GetMessage( string worldName, WorldOpExceptionCode code ) {
            if( worldName != null ) {
                switch( code ) {
                    case WorldOpExceptionCode.CannotDoThatToMainWorld:
                        return "This operation cannot be done on the main world (" +
                               worldName + "). Assign a new main world and try again.";

                    case WorldOpExceptionCode.DuplicateWorldName:
                        return "A world with this name (\"" + worldName + "\") already exists.";

                    case WorldOpExceptionCode.InvalidWorldName:
                        return "World name \"" + worldName + "\" is invalid. " +
                               "Expected an alphanumeric name between 1 and 16 characters long.";

                    case WorldOpExceptionCode.MapLoadError:
                        return "Failed to load the map file for world \"" + worldName + "\".";

                    case WorldOpExceptionCode.MapMoveError:
                        return "Failed to rename/move the map file for world \"" + worldName + "\".";

                    case WorldOpExceptionCode.MapNotFound:
                        return "Could not find the map file for world \"" + worldName + "\".";

                    case WorldOpExceptionCode.MapPathError:
                        return "Map file path is not valid for world \"" + worldName + "\".";

                    case WorldOpExceptionCode.MapSaveError:
                        return "Failed to save the map file for world \"" + worldName + "\".";

                    case WorldOpExceptionCode.NoChangeNeeded:
                        return "No change needed for world \"" + worldName + "\".";

                    case WorldOpExceptionCode.Cancelled:
                        return "Operation for world \"" + worldName + "\" was cancelled by a plugin.";

                    case WorldOpExceptionCode.SecurityError:
                        return "You are not allowed to do this operation to world \"" + worldName + "\".";

                    case WorldOpExceptionCode.Unexpected:
                        return "Unexpected problem occured with world \"" + worldName + "\".";

                    case WorldOpExceptionCode.WorldNotFound:
                        return "No world found with the name \"" + worldName + "\".";

                    default:
                        return "Unexpected error occured while working on world \"" + worldName + "\"";
                }
            } else {
                switch( code ) {
                    case WorldOpExceptionCode.CannotDoThatToMainWorld:
                        return "This operation cannot be done on the main world. " +
                               "Assign a new main world and try again.";

                    case WorldOpExceptionCode.DuplicateWorldName:
                        return "A world with this name already exists.";

                    case WorldOpExceptionCode.InvalidWorldName:
                        return "Given world name is invalid. " +
                               "Expected an alphanumeric name between 1 and 16 characters long.";

                    case WorldOpExceptionCode.MapLoadError:
                        return "Failed to load the map file.";

                    case WorldOpExceptionCode.MapMoveError:
                        return "Failed to rename/move the map file.";

                    case WorldOpExceptionCode.MapNotFound:
                        return "Could not find the map file.";

                    case WorldOpExceptionCode.MapPathError:
                        return "Map file path is not valid.";

                    case WorldOpExceptionCode.MapSaveError:
                        return "Failed to save the map file.";

                    case WorldOpExceptionCode.NoChangeNeeded:
                        return "No change needed.";

                    case WorldOpExceptionCode.Cancelled:
                        return "Operation cancelled by a plugin.";

                    case WorldOpExceptionCode.SecurityError:
                        return "You are not allowed to do this operation.";

                    case WorldOpExceptionCode.Unexpected:
                        return "Unexpected problem occured.";

                    case WorldOpExceptionCode.WorldNotFound:
                        return "Specified world was not found.";

                    default:
                        return "Unexpected error occured.";
                }
            }
        }
Exemplo n.º 5
0
 public WorldOpException(WorldOpExceptionCode errorCode, string message)
     : base(message)
 {
     ErrorCode = errorCode;
 }
Exemplo n.º 6
0
 public WorldOpException( WorldOpExceptionCode errorCode, string message, Exception innerException )
     : base( message, innerException ) {
     ErrorCode = errorCode;
 }
Exemplo n.º 7
0
 public WorldOpException( string worldName, WorldOpExceptionCode errorCode, Exception innerException )
     : base( GetMessage( worldName, errorCode ), innerException ) {
     ErrorCode = errorCode;
 }
Exemplo n.º 8
0
 public WorldOpException( WorldOpExceptionCode errorCode, string message )
     : base( message ) {
     ErrorCode = errorCode;
 }
Exemplo n.º 9
0
 /// <summary> Creates a new instance of fCraft.WorldOpException, with the specified world and error code. </summary>
 /// <param name="worldName"> World where exception took place. May be null if no relevant world exists. </param>
 /// <param name="errorCode"> Error that took place. </param>
 public WorldOpException([CanBeNull] string worldName, WorldOpExceptionCode errorCode)
     : base(GetMessage(worldName, errorCode))
 {
     ErrorCode = errorCode;
 }
Exemplo n.º 10
0
 /// <summary> Creates a new instance of fCraft.WorldOpException, with the specified world and error code. </summary>
 /// <param name="worldName"> World where exception took place. May be null if no relevant world exists. </param>
 /// <param name="errorCode"> Error that took place. </param>
 public WorldOpException( [CanBeNull] string worldName, WorldOpExceptionCode errorCode )
     : base( GetMessage( worldName, errorCode ) ) {
     ErrorCode = errorCode;
 }