统一 Rust 与 TypeScript 格式化门禁
纳入 AGC Cargo workspace 的统一 rustfmt 检查与格式化入口 完成项目 TypeScript/Prettier 与 Rust 全量格式化 修复 Pingora expected executable 门禁的空白敏感误报 同步开发运维文档与 AGC skill pack 格式化忽略规则
This commit is contained in:
@@ -35,8 +35,7 @@ export const ASSET_API_PATHS = {
|
||||
characterAnimationTemplates: `${ASSETS_API_BASE_PATH}/character-animation/templates`,
|
||||
} as const;
|
||||
|
||||
export const EDITOR_ITEM_CATALOG_API_PATH =
|
||||
`${EDITOR_API_BASE_PATH}/catalog/items`;
|
||||
export const EDITOR_ITEM_CATALOG_API_PATH = `${EDITOR_API_BASE_PATH}/catalog/items`;
|
||||
|
||||
export function buildEditorJsonApiPath(resourceId: EditorJsonResourceId) {
|
||||
return `${EDITOR_API_BASE_PATH}/json/${resourceId}`;
|
||||
@@ -74,7 +73,12 @@ export async function postApiJson<T>(
|
||||
const responseText = await response.text();
|
||||
|
||||
if (!response.ok) {
|
||||
throw new Error(appendApiErrorRequestId(parseApiErrorMessage(responseText, fallbackMessage), response.headers.get('x-request-id')));
|
||||
throw new Error(
|
||||
appendApiErrorRequestId(
|
||||
parseApiErrorMessage(responseText, fallbackMessage),
|
||||
response.headers.get('x-request-id'),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
return responseText ? (JSON.parse(responseText) as T) : ({} as T);
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import {describe, expect, it} from 'vitest';
|
||||
import { describe, expect, it } from 'vitest';
|
||||
|
||||
import {parseApiErrorMessage} from './jsonClient';
|
||||
import { parseApiErrorMessage } from './jsonClient';
|
||||
|
||||
describe('parseApiErrorMessage', () => {
|
||||
it('prefers api error detail messages for business failures', () => {
|
||||
@@ -40,10 +40,14 @@ describe('parseApiErrorMessage', () => {
|
||||
});
|
||||
|
||||
it('falls back to the raw response text when the payload is not json', () => {
|
||||
expect(parseApiErrorMessage('Plain text failure', 'Fallback failure')).toBe('Plain text failure');
|
||||
expect(parseApiErrorMessage('Plain text failure', 'Fallback failure')).toBe(
|
||||
'Plain text failure',
|
||||
);
|
||||
});
|
||||
|
||||
it('uses the fallback when the response body is empty', () => {
|
||||
expect(parseApiErrorMessage('', 'Fallback failure')).toBe('Fallback failure');
|
||||
expect(parseApiErrorMessage('', 'Fallback failure')).toBe(
|
||||
'Fallback failure',
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user