forked from gordon-matt/elFinder.NetCore
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathError.cs
More file actions
98 lines (87 loc) · 2.47 KB
/
Copy pathError.cs
File metadata and controls
98 lines (87 loc) · 2.47 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
namespace elFinder.NetCore.Helpers;
// For a list of all possible error messages: https://github.com/Studio-42/elFinder/blob/master/js/i18n/elfinder.en.js
public static class Error
{
/// <summary>
/// Access denied.
/// </summary>
/// <returns></returns>
public static JsonResult AccessDenied()
{
return FormatSimpleError("errAccess");
}
/// <summary>
/// File not found.
/// </summary>
/// <returns></returns>
public static JsonResult FileNotFound()
{
return FormatSimpleError("errFileNotFound");
}
/// <summary>
/// File type not allowed.
/// </summary>
/// <returns></returns>
public static JsonResult FileTypeNotAllowed()
{
return FormatSimpleError("errUploadMime");
}
/// <summary>
/// Folder not found.
/// </summary>
/// <returns></returns>
public static JsonResult FolderNotFound()
{
return FormatSimpleError("errFolderNotFound");
}
/// <summary>
/// Invalid parameters for command "$1".
/// </summary>
/// <param name="command"></param>
/// <returns></returns>
public static JsonResult InvalidCommandParams(string command)
{
return new JsonResult(new { error = new string[] { "errCmdParams", command } });
}
// NOTE: This is a custom error (not out-of-the-box) defined on client side.
/// <summary>
/// Unable to create new file with name "$1"
/// </summary>
/// <param name="name"></param>
/// <returns></returns>
public static JsonResult NewNameSelectionException(string name)
{
return new JsonResult(new
{
error = new[] { "errNewNameSelection", name }
});
}
/// <summary>
/// Unable to upload "$1".
/// </summary>
/// <returns></returns>
public static JsonResult UnableToUpload()
{
return FormatSimpleError("errUploadFile");
}
/// <summary>
/// Unknown command.
/// </summary>
/// <returns></returns>
public static JsonResult UnknownCommand()
{
return FormatSimpleError("errUnknownCmd");
}
/// <summary>
/// File exceeds maximum allowed size.
/// </summary>
/// <returns></returns>
public static JsonResult UploadFileTooLarge()
{
return FormatSimpleError("errUploadFileSize"); // old name - errFileMaxSize
}
private static JsonResult FormatSimpleError(string message)
{
return new JsonResult(new { error = message });
}
}