forked from geolba/tethys.backend
- use latest prettier 3.0 with eslint-plugin-prettier: 5.0.0-alpha.2
- npm normal updates - add all xslt and style asstes in extra folder public/assets2 - linting corrections - delete local .env.test from git tracking: git rm --cached .env.test - add .env.test into .gitignore file - add edit functionality for editing by submitter - npm updates -added xslt3 packeage for builfing sef files - added Language.ts class vor language table - added version to datasetxml2oai-pmh.xslt
This commit is contained in:
parent
f403c3109f
commit
4714dfdd94
70 changed files with 22920 additions and 17407 deletions
|
@ -22,14 +22,14 @@ export default class InvalidCredentialException extends Exception {
|
|||
/**
|
||||
* Unable to find user
|
||||
*/
|
||||
static invalidUid() {
|
||||
public static invalidUid() {
|
||||
const error = new this('User not found', 400, 'E_INVALID_AUTH_UID');
|
||||
return error;
|
||||
}
|
||||
/**
|
||||
* Invalid user password
|
||||
*/
|
||||
static invalidPassword() {
|
||||
public static invalidPassword() {
|
||||
const error = new this('Password mis-match', 400, 'E_INVALID_AUTH_PASSWORD');
|
||||
return error;
|
||||
}
|
||||
|
@ -59,7 +59,7 @@ export default class InvalidCredentialException extends Exception {
|
|||
* Handle this exception by itself
|
||||
*/
|
||||
|
||||
handle(error, ctx) {
|
||||
public handle(error, ctx) {
|
||||
// return response.status(403).view.render("errors/unauthorized", {
|
||||
// error: error,
|
||||
// });
|
||||
|
|
48
app/Exceptions/OaiErrorCodes.ts
Normal file
48
app/Exceptions/OaiErrorCodes.ts
Normal file
|
@ -0,0 +1,48 @@
|
|||
export enum OaiErrorCodes {
|
||||
BADVERB = 1010,
|
||||
BADARGUMENT = 1011,
|
||||
CANNOTDISSEMINATEFORMAT = 1012,
|
||||
BADRESUMPTIONTOKEN = 1013,
|
||||
NORECORDSMATCH = 1014,
|
||||
IDDOESNOTEXIST = 1015,
|
||||
}
|
||||
|
||||
// 👇️ default export
|
||||
// export { OaiErrorCodes };
|
||||
|
||||
// https://medium.com/@juliapassynkova/map-your-typescript-enums-e402d406b229
|
||||
export const OaiModelError = new Map<number, string>([
|
||||
[OaiErrorCodes.BADVERB, 'badVerb'],
|
||||
[OaiErrorCodes.BADARGUMENT, 'badArgument'],
|
||||
[OaiErrorCodes.NORECORDSMATCH, 'noRecordsMatch'],
|
||||
[OaiErrorCodes.CANNOTDISSEMINATEFORMAT, 'cannotDisseminateFormat'],
|
||||
[OaiErrorCodes.BADRESUMPTIONTOKEN, 'badResumptionToken'],
|
||||
[OaiErrorCodes.IDDOESNOTEXIST, 'idDoesNotExist'],
|
||||
]);
|
||||
|
||||
// class OaiModelError {
|
||||
// // const BADVERB = 1010;
|
||||
// // const BADARGUMENT = 1011;
|
||||
// // const CANNOTDISSEMINATEFORMAT = 1012;
|
||||
// // const BADRESUMPTIONTOKEN = 1013;
|
||||
// // const NORECORDSMATCH = 1014;
|
||||
// // const IDDOESNOTEXIST = 1015;
|
||||
|
||||
// protected static $oaiErrorCodes = {
|
||||
// OaiErrorCodes. 'badVerb',
|
||||
// BADARGUMENT : 'badArgument',
|
||||
// NORECORDSMATCH: 'noRecordsMatch',
|
||||
// CANNOTDISSEMINATEFORMAT: 'cannotDisseminateFormat',
|
||||
// BADRESUMPTIONTOKEN: 'badResumptionToken',
|
||||
// IDDOESNOTEXIST: 'idDoesNotExist',
|
||||
// };
|
||||
|
||||
// public static function mapCode($code)
|
||||
// {
|
||||
// if (false === array_key_exists($code, self::$oaiErrorCodes)) {
|
||||
// throw new OaiModelException("Unknown oai error code $code");
|
||||
// }
|
||||
// return self::$oaiErrorCodes[$code];
|
||||
// }
|
||||
|
||||
// }
|
77
app/Exceptions/OaiModelException.ts
Normal file
77
app/Exceptions/OaiModelException.ts
Normal file
|
@ -0,0 +1,77 @@
|
|||
import { StatusCodes } from 'http-status-codes';
|
||||
// import HTTPException from './HttpException';
|
||||
import { OaiErrorCodes } from './OaiErrorCodes';
|
||||
|
||||
export class ErrorCode {
|
||||
public static readonly Unauthenticated = 'Unauthenticated';
|
||||
public static readonly NotFound = 'NotFound';
|
||||
public static readonly MaximumAllowedGrade = 'MaximumAllowedGrade';
|
||||
public static readonly AsyncError = 'AsyncError';
|
||||
public static readonly UnknownError = 'UnknownError';
|
||||
}
|
||||
|
||||
export class ErrorModel {
|
||||
/**
|
||||
* Unique error code which identifies the error.
|
||||
*/
|
||||
public code: string;
|
||||
/**
|
||||
* Status code of the error.
|
||||
*/
|
||||
public status: number;
|
||||
/**
|
||||
* Any additional data that is required for translation.
|
||||
*/
|
||||
// public metaData?: any;
|
||||
}
|
||||
|
||||
export class OaiModelException extends Error {
|
||||
public status: number;
|
||||
public message: string;
|
||||
public oaiCode: number;
|
||||
|
||||
// constructor(status: number, message: string) {
|
||||
// super(message);
|
||||
// this.status = status;
|
||||
// this.message = message;
|
||||
// }
|
||||
constructor(status: number, message: string, oaiCode: number) {
|
||||
super(message);
|
||||
this.status = status;
|
||||
this.message = message;
|
||||
this.oaiCode = oaiCode;
|
||||
}
|
||||
// constructor(code: string = ErrorCode.UnknownError, message: any = null) {
|
||||
// super(code);
|
||||
// Object.setPrototypeOf(this, new.target.prototype);
|
||||
// this.name = code;
|
||||
// this.status = 500;
|
||||
// this.message = message;
|
||||
// // switch (code) {
|
||||
// // case ErrorCode.Unauthenticated:
|
||||
// // this.status = 401;
|
||||
// // break;
|
||||
// // case ErrorCode.MaximumAllowedGrade:
|
||||
// // this.status = 400;
|
||||
// // break;
|
||||
// // case ErrorCode.AsyncError:
|
||||
// // this.status = 400;
|
||||
// // break;
|
||||
// // case ErrorCode.NotFound:
|
||||
// // this.status = 404;
|
||||
// // break;
|
||||
// // default:
|
||||
// // this.status = 500;
|
||||
// // break;
|
||||
// // }
|
||||
// }
|
||||
}
|
||||
|
||||
export class BadOaiModelException extends OaiModelException {
|
||||
constructor(message?: string) {
|
||||
super(StatusCodes.INTERNAL_SERVER_ERROR, message || 'bad Request', OaiErrorCodes.BADARGUMENT);
|
||||
this.stack = '';
|
||||
}
|
||||
}
|
||||
|
||||
// export default OaiModelexception;
|
Loading…
Add table
editor.link_modal.header
Reference in a new issue