Skip to content

Commit

Permalink
Display error to the user if comfyui api failed to get object info
Browse files Browse the repository at this point in the history
  • Loading branch information
AbdullahAlfaraj committed Nov 19, 2023
1 parent c113753 commit 3fd3a4f
Showing 1 changed file with 17 additions and 3 deletions.
20 changes: 17 additions & 3 deletions typescripts/comfyui/comfyapi.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { app } from 'photoshop'
import settings_tab from '../settings/settings'
import { requestGet, requestPost } from '../util/ts/api'
import { base64UrlToBase64 } from '../util/ts/general'
Expand All @@ -20,12 +21,21 @@ export interface ComfyResult {
class ComfyAPI {
private object_info: Record<string, any> = {}
comfy_url: string
status: boolean = false

constructor(comfy_url: string) {
this.comfy_url = comfy_url
}
async init() {
this.object_info = await this.getObjectInfo(this.comfy_url)
return this.object_info
try {
this.object_info = await this.getObjectInfo(this.comfy_url)
this.status = true
return this.object_info
} catch (e) {
console.error(e)
app.showAlert(`${e}`)
this.status = false
}
}
setUrl(comfy_url: string) {
this.comfy_url = comfy_url
Expand Down Expand Up @@ -74,10 +84,14 @@ class ComfyAPI {

async getObjectInfo(comfy_url: string) {
try {
const object_info = await requestGet(`${comfy_url}/object_info`)
const full_url = `${comfy_url}/object_info`
const object_info = await requestGet(full_url)
if (!object_info)
throw `can not request from comfyui url: ${comfy_url}`
return object_info
} catch (e) {
console.error(e)
throw e
}
}
getReadableError(result: ComfyResult): string {
Expand Down

0 comments on commit 3fd3a4f

Please sign in to comment.