mirror of
https://github.com/FranP-code/Baileys.git
synced 2025-10-13 00:32:22 +00:00
Listen for errors on got stream
This commit is contained in:
@@ -40,7 +40,7 @@ export class WAConnection extends Base {
|
|||||||
type: MessageType,
|
type: MessageType,
|
||||||
options: MessageOptions = {},
|
options: MessageOptions = {},
|
||||||
) {
|
) {
|
||||||
const content = await this.prepareMessageContent (
|
const content = await this.prepareMessageContent(
|
||||||
message,
|
message,
|
||||||
type,
|
type,
|
||||||
options
|
options
|
||||||
|
|||||||
@@ -294,8 +294,9 @@ export async function generateThumbnail(file: string, mediaType: MessageType, in
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
export const getGotStream = async(url: string | URL, options: Options & { isStream?: true } = {}) => {
|
export const getGotStream = async(url: string | URL, options: Options & { isStream?: true } = {}) => {
|
||||||
const fetched = got.stream(url, options)
|
const fetched = got.stream(url, { ...options, isStream: true })
|
||||||
await new Promise((resolve, reject) => {
|
await new Promise((resolve, reject) => {
|
||||||
|
fetched.once('error', reject)
|
||||||
fetched.once('response', ({statusCode: status}: Response) => {
|
fetched.once('response', ({statusCode: status}: Response) => {
|
||||||
if (status >= 400) {
|
if (status >= 400) {
|
||||||
reject(new BaileysError (
|
reject(new BaileysError (
|
||||||
|
|||||||
Reference in New Issue
Block a user