OXIESEC PANEL
- Current Dir:
/
/
var
/
www
/
reader
/
_backup
/
tinymce
/
tinymce
/
src
/
themes
/
silver
/
main
/
ts
/
ui
/
dialog
/
imagetools
Server IP: 139.59.38.164
Upload:
Create Dir:
Name
Size
Modified
Perms
📁
..
-
02/20/2020 06:40:38 AM
rwxr-xr-x
📄
CropRect.ts
7.1 KB
02/20/2020 06:40:41 AM
rw-r--r--
📄
DragHelper.ts
3.43 KB
02/20/2020 06:40:41 AM
rw-r--r--
📄
EditPanel.ts
15.6 KB
02/20/2020 06:40:42 AM
rw-r--r--
📄
Errors.ts
2.39 KB
02/20/2020 06:40:42 AM
rw-r--r--
📄
ImagePanel.ts
6.88 KB
02/20/2020 06:40:43 AM
rw-r--r--
📄
ImageTools.ts
7.94 KB
02/20/2020 06:40:43 AM
rw-r--r--
📄
ImageToolsEvents.ts
1.17 KB
02/20/2020 06:40:44 AM
rw-r--r--
📄
SideBar.ts
2.62 KB
02/20/2020 06:40:44 AM
rw-r--r--
📄
UndoStack.ts
842 bytes
02/20/2020 06:40:45 AM
rw-r--r--
📄
Utils.ts
1.8 KB
02/20/2020 06:40:45 AM
rw-r--r--
📁
state
-
02/20/2020 06:42:44 AM
rwxr-xr-x
Editing: Errors.ts
Close
/** * Copyright (c) Tiny Technologies, Inc. All rights reserved. * Licensed under the LGPL or a commercial license. * For LGPL see License.txt in the project root for license information. * For commercial licenses see https://www.tiny.cloud/ */ import { Arr, Fun } from '@ephox/katamari'; import Promise from 'tinymce/core/api/util/Promise'; import Utils from './Utils'; const friendlyHttpErrors = [ { code: 404, message: 'Could not find Image Proxy' }, { code: 403, message: 'Rejected request' }, { code: 0, message: 'Incorrect Image Proxy URL' } ]; const friendlyServiceErrors = [ { type: 'key_missing', message: 'The request did not include an api key.' }, { type: 'key_not_found', message: 'The provided api key could not be found.' }, { type: 'domain_not_trusted', message: 'The api key is not valid for the request origins.' } ]; const isServiceErrorCode = function (code) { return code === 400 || code === 403 || code === 500; }; const getHttpErrorMsg = function (status) { const message = Arr.find(friendlyHttpErrors, function (error) { return status === error.code; }).fold( Fun.constant('Unknown ImageProxy error'), function (error) { return error.message; } ); return 'ImageProxy HTTP error: ' + message; }; const handleHttpError = function (status) { const message = getHttpErrorMsg(status); return Promise.reject(message); }; const getServiceErrorMsg = function (type) { return Arr.find(friendlyServiceErrors, function (error) { return error.type === type; }).fold( Fun.constant('Unknown service error'), function (error) { return error.message; } ); }; const getServiceError = function (text) { const serviceError = Utils.parseJson(text); const errorType = Utils.traverse(serviceError, ['error', 'type']); const errorMsg = errorType ? getServiceErrorMsg(errorType) : 'Invalid JSON in service error message'; return 'ImageProxy Service error: ' + errorMsg; }; const handleServiceError = function (status, blob) { return Utils.readBlob(blob).then(function (text) { const serviceError = getServiceError(text); return Promise.reject(serviceError); }); }; const handleServiceErrorResponse = function (status, blob) { return isServiceErrorCode(status) ? handleServiceError(status, blob) : handleHttpError(status); }; export default { handleServiceErrorResponse, handleHttpError, getHttpErrorMsg, getServiceErrorMsg };