我的订阅不处理错误(My subscription is not handling errors)
我订阅了一项服务,我从外部API请求图像URL并将其存储在共享服务中。
逻辑:
1.清空当前图像阵列
2.从API请求图像,并将其推送到(新清除的)数组(response =>)
3.如果URL返回错误,请使用默认(占位符)图像填充数组(error =>)出于某种原因,尽管存在错误,但仍未处理错误。 我已经发布了我的组件和错误消息的上下文。
Component.ts
getImages(vehicleID: number, color: string): void { this._carConfigService.car.colors.exterior.urls = []; this._FAPIService.getImagesForColors(vehicleID, color) .subscribe( response => { response.products[0].productFormats.forEach(pF => { this._carConfigService.car.colors.exterior.urls.push(pF.assets[0].url); }); }, error => { this.errorMessage = <any>error; if (this._carConfigService.car.colors.exterior.urls.length === 0) { this._carConfigService.car.colors.exterior.urls = this._carConfigService.defaultImages; } }); }
我收到以下错误:
Failed to load resource: the server responded with a status of 422 () EXCEPTION: Response with status: 0 for URL: null Uncaught Response
I have a subscription to a service where I request image URLs from an external API and store it in a shared service.
The Logic:
1. Empty the current images array
2. Request images from API, and push it to the (newly cleared) array (response =>)
3. If the URL returns an error, fill up the array with default (placeholder) images (error =>)For some reason, the error isn't being handled despite there being one. I have posted my component and error messages for context.
Component.ts
getImages(vehicleID: number, color: string): void { this._carConfigService.car.colors.exterior.urls = []; this._FAPIService.getImagesForColors(vehicleID, color) .subscribe( response => { response.products[0].productFormats.forEach(pF => { this._carConfigService.car.colors.exterior.urls.push(pF.assets[0].url); }); }, error => { this.errorMessage = <any>error; if (this._carConfigService.car.colors.exterior.urls.length === 0) { this._carConfigService.car.colors.exterior.urls = this._carConfigService.defaultImages; } }); }
I receive the following errors:
Failed to load resource: the server responded with a status of 422 () EXCEPTION: Response with status: 0 for URL: null Uncaught Response
原文:https://stackoverflow.com/questions/42725600
最满意答案
你可以运行本地连接到你的Heroku提供的Postgres实例的pg_restore。 从中获取数据库凭据
heroku config
从database_url键中将它们作为选项在本地传递给pg_restore。 然后你还应该能够使用-t开关来恢复你的特定表。
You can run pg_restore locally connected to your Heroku provided Postgres instance. Get you db credentials from
heroku config
From the database_url key and pass them into pg_restore locally as options. Then you should also be able to use the -t switch to restore your specific table.
相关问答
更多-
我也无法将其与Cloud App配合使用,但使用Dropbox成功。 I too could not get this to work with Cloud App, but was successful using Dropbox.
-
将数据附加到heroku表(Append data to heroku table)[2023-08-07]
想出这个网站的礼貌。 只需运行此命令: psql `heroku config:get DATABASE_URL -a your_app`?ssl=true -c "\copy your_table FROM '/tmp/rows.csv' WITH CSV;" your_app和your_table被适当替换的位置。 Figured it out, courtesy of this site. Just run this command: psql `heroku config:get DATABASE ... -
pgbackup可以从同一个应用程序的数据库或任何pgbackups URL恢复,就像在源应用程序/数据库中捕获的那个一样。 这些指令使用反引号(`)来弹出并从源应用程序中获取pgbackups URL。 pgbackups:url命令将提供这样的URL。 尝试运行它,以了解发生了什么: heroku pgbackups:url -a costrecovery (假设costrecovery是您捕获数据的地方)。 知道这一点,你应该能够简单地运行: heroku pgbackups:restore DAT ...
-
据推测,您的应用程序正在从环境变量DATABASE_URL读取。 如果您有多个数据库,那么您还应该有其他环境变量,如HEROKU_POSTGRESQL_(color) 。 您可以从应用程序中访问这些环境变量以检查配置的数据库信息,您可以在Heroku面板中更改它们。 如果您将DATABASE_URL更改为HEROKU_POSTGRESQL_(color)之一的值,那么您的应用程序应该选择该项并切换到其他数据库。 您还可以编辑配置并访问另一个环境变量,同时完全绕过DATABASE_URL。 Presumabl ...
-
没找到Heroku postgres(Heroku postgres not found)[2023-04-06]
通过降级Rails和Ruby来解决这个问题:( 现在我使用rails 3.1.0和ruby 1.9.3 Solved this by downgrading Rails and Ruby :( Now I'm using rails 3.1.0 and ruby 1.9.3 -
解: 按pgbackups:restore运行pgbackups:restore (并获取错误)。 运行heroku restart 。 运行heroku pg:psql (利润)。 出于某种原因,在pg:restore之后数据库工作之前,似乎有必要restart然后再使用pg:psql 。 即使pg:psql很乐意显示表确实存在(与日志消息相反),应用程序将无法工作,直到dyno重新启动(然后它仍然无法工作),直到你pg:psql 。 据我所知, pg:psql只建立了与远程数据库的连接,并且不应该对数据 ...
-
您可以使用heroku pg:credentials DATABASE或heroku config查看当前凭据。 然后,您可以使用显示的URL元素通过数据库管理工具(如Pgadmin)进行连接。 密码是:和@之间的文本。 You can see your current credentials with heroku pg:credentials DATABASE or heroku config. You can then use the elements of the URL displayed to ...
-
您的.dump文件应该是一个pg_dump文件,因此您需要在某处设置PostgreSQL,然后使用pg_restore将.dump文件加载到本地数据库中。 Your .dump file should be a pg_dump file so you'd need to set up PostgreSQL somewhere and then use pg_restore to load the .dump file into your local database.
-
Heroku完全管理每天为您备份数据库,而无需您做任何事情。 所有备份(无论是手动还是自动)都可供您导出。 您可以通过在命令行键入以下内容来获取这些列表: $ heroku pgbackups --app your_app_name_goes_here 您可以在此处找到有关还原或导出到本地计算机的更多信息: http : //devcenter.heroku.com/articles/pgbackups Heroku fully manages backing up the database daily ...
-
你可以运行本地连接到你的Heroku提供的Postgres实例的pg_restore。 从中获取数据库凭据 heroku config 从database_url键中将它们作为选项在本地传递给pg_restore。 然后你还应该能够使用-t开关来恢复你的特定表。 You can run pg_restore locally connected to your Heroku provided Postgres instance. Get you db credentials from heroku conf ...