mirror of
https://gitcode.com/gh_mirrors/hy/Hydro.git
synced 2026-10-20 01:38:19 +08:00
core: send: 区分远端错误与本地错误
This commit is contained in:
1 parent
6f96e7fa9e
commit
f2fbbb8af9
4 files changed
+29
-10
No files matched your search
@@ -6,7 +6,8 @@ import serialize from 'serialize-javascript';
|
||||
import Lru from 'lru-cache';
|
||||
import { ObjectID } from 'mongodb';
|
||||
import { isMoment } from 'moment';
|
||||
import { Moment } from 'moment-timezone';
|
||||
import type { Moment } from 'moment-timezone';
|
||||
import type { Logger } from './logger';
|
||||
|
||||
declare global {
|
||||
interface StringConstructor {
|
||||
@@ -220,6 +221,13 @@ function deepen(modifyString: (source: string) => string) {
|
||||
};
|
||||
}
|
||||
|
||||
export function logAndReturn(logger: Logger) {
|
||||
return function cb(err: Error) {
|
||||
logger.error(err);
|
||||
return err;
|
||||
};
|
||||
}
|
||||
|
||||
export const camelCase = deepen((source) => source.replace(/[_-][a-z]/g, (str) => str.slice(1).toUpperCase()));
|
||||
export const paramCase = deepen((source) => source.replace(/_/g, '-').replace(/(?<!^)[A-Z]/g, (str) => `-${str.toLowerCase()}`));
|
||||
export const snakeCase = deepen((source) => source.replace(/-/g, '_').replace(/(?<!^)[A-Z]/g, (str) => `_${str.toLowerCase()}`));
|
||||
|
||||
Reference in new issue
Block a user