fix: snippet not found throw

This commit is contained in:
Innei
2022-03-12 23:12:53 +08:00
parent 29c9984332
commit cf91ff81ba
2 changed files with 4 additions and 1 deletions

View File

@@ -58,7 +58,7 @@ export class ServerlessController {
})
if (!snippet) {
throw new NotFoundException('snippet is not found')
throw new NotFoundException('serverless function is not exist')
}
if (snippet.private && !isMaster) {

View File

@@ -99,6 +99,9 @@ export class SnippetService {
*/
async getSnippetByName(name: string, reference: string) {
const doc = await this.model.findOne({ name, reference }).lean()
if (!doc) {
throw new NotFoundException('snippet is not found')
}
return doc
}