fixing throw error & message error
This commit is contained in:
parent
488b3b0923
commit
da710215ec
1 changed files with 10 additions and 10 deletions
|
|
@ -63,12 +63,12 @@ export class DocumentController extends Controller {
|
||||||
public async getFile(@Path() volume: string, @Path() id: string) {
|
public async getFile(@Path() volume: string, @Path() id: string) {
|
||||||
try {
|
try {
|
||||||
const list = await listFile(["ระบบประเมิน", volume, id]);
|
const list = await listFile(["ระบบประเมิน", volume, id]);
|
||||||
if (!list) throw new Error("เกิดข้อผิดพลาดกับระบบจัดการไฟล์ ไม่สามารถสร้างแฟ้มได้");
|
if (!list) throw new Error("เกิดข้อผิดพลาดกับระบบจัดการไฟล์ ไม่สามารถอ่านแฟ้มได้");
|
||||||
return list;
|
return list;
|
||||||
} catch (error: any) {
|
} catch (error: any) {
|
||||||
if (error instanceof HttpError) {
|
if (error instanceof HttpError) {
|
||||||
throw error;
|
throw error;
|
||||||
} else throw new HttpError(HttpStatusCode.INTERNAL_SERVER_ERROR, error);
|
} else throw new HttpError(HttpStatusCode.INTERNAL_SERVER_ERROR, error.message);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -108,12 +108,12 @@ export class DocumentController extends Controller {
|
||||||
public async getFileDownload(@Path() id: string, @Path() volume: string, @Path() file: string) {
|
public async getFileDownload(@Path() id: string, @Path() volume: string, @Path() file: string) {
|
||||||
try {
|
try {
|
||||||
const data = await downloadFile(["ระบบประเมิน", volume, id], file);
|
const data = await downloadFile(["ระบบประเมิน", volume, id], file);
|
||||||
if (!data) throw new Error("เกิดข้อผิดพลาดกับระบบจัดการไฟล์ ไม่สามารถสร้างแฟ้มได้");
|
if (!data) throw new Error("เกิดข้อผิดพลาดกับระบบจัดการไฟล์ ไม่สามารถดาวน์โหลดไฟล์ได้");
|
||||||
return data;
|
return data;
|
||||||
} catch (error: any) {
|
} catch (error: any) {
|
||||||
if (error instanceof HttpError) {
|
if (error instanceof HttpError) {
|
||||||
throw error;
|
throw error;
|
||||||
} else throw new HttpError(HttpStatusCode.INTERNAL_SERVER_ERROR, error);
|
} else throw new HttpError(HttpStatusCode.INTERNAL_SERVER_ERROR, error.message);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -219,7 +219,7 @@ export class DocumentController extends Controller {
|
||||||
const list = await listFile(["ระบบประเมิน", volume, id]);
|
const list = await listFile(["ระบบประเมิน", volume, id]);
|
||||||
|
|
||||||
if (!list || !Array.isArray(list)) {
|
if (!list || !Array.isArray(list)) {
|
||||||
throw new Error("เกิดข้อผิดพลาดกับระบบจัดการไฟล์ ไม่สามารถสร้างแฟ้มได้");
|
throw new Error("เกิดข้อผิดพลาดกับระบบจัดการไฟล์ ไม่สามารถอ่านแฟ้มได้");
|
||||||
}
|
}
|
||||||
|
|
||||||
// let used: string[] = [];
|
// let used: string[] = [];
|
||||||
|
|
@ -299,7 +299,7 @@ export class DocumentController extends Controller {
|
||||||
} catch (error: any) {
|
} catch (error: any) {
|
||||||
if (error instanceof HttpError) {
|
if (error instanceof HttpError) {
|
||||||
throw error;
|
throw error;
|
||||||
} else throw new HttpError(HttpStatusCode.INTERNAL_SERVER_ERROR, error);
|
} else throw new HttpError(HttpStatusCode.INTERNAL_SERVER_ERROR, error.message);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -336,7 +336,7 @@ export class DocumentController extends Controller {
|
||||||
} catch (error: any) {
|
} catch (error: any) {
|
||||||
if (error instanceof HttpError) {
|
if (error instanceof HttpError) {
|
||||||
throw error;
|
throw error;
|
||||||
} else throw new HttpError(HttpStatusCode.INTERNAL_SERVER_ERROR, error);
|
} else throw new HttpError(HttpStatusCode.INTERNAL_SERVER_ERROR, error.message);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -358,7 +358,7 @@ export class DocumentController extends Controller {
|
||||||
} catch (error: any) {
|
} catch (error: any) {
|
||||||
if (error instanceof HttpError) {
|
if (error instanceof HttpError) {
|
||||||
throw error;
|
throw error;
|
||||||
} else throw new HttpError(HttpStatusCode.INTERNAL_SERVER_ERROR, error);
|
} else throw new HttpError(HttpStatusCode.INTERNAL_SERVER_ERROR, error.message);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -375,13 +375,13 @@ export class DocumentController extends Controller {
|
||||||
const result = await deleteFile(["ระบบประเมิน", volume, id], file);
|
const result = await deleteFile(["ระบบประเมิน", volume, id], file);
|
||||||
|
|
||||||
if (!result) {
|
if (!result) {
|
||||||
throw new Error("เกิดข้อผิดพลาดกับระบบจัดการไฟล์ ไม่สามารถอัปโหลดไฟล์ได้");
|
throw new Error("เกิดข้อผิดพลาดกับระบบจัดการไฟล์ ไม่สามารถลบไฟล์ได้");
|
||||||
}
|
}
|
||||||
return this.setStatus(HttpStatus.NO_CONTENT);
|
return this.setStatus(HttpStatus.NO_CONTENT);
|
||||||
} catch (error: any) {
|
} catch (error: any) {
|
||||||
if (error instanceof HttpError) {
|
if (error instanceof HttpError) {
|
||||||
throw error;
|
throw error;
|
||||||
} else throw new HttpError(HttpStatusCode.INTERNAL_SERVER_ERROR, error);
|
} else throw new HttpError(HttpStatusCode.INTERNAL_SERVER_ERROR, error.message);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue