chatch / stellarexplorer

Ledger Explorer for the Stellar Network šŸš€
https://steexp.com
Apache License 2.0
457 stars 1.06k forks source link

SSR server side error NotFound not translated correctly #525

Closed chatch closed 1 year ago

chatch commented 1 year ago

When an entity is not found on horizon it should return a 404 on the browser. However the server side catches this error but instead returns 500 to the browser which renders "Unexcepted Server Error":

[info] NotFoundError: Not Found
[info] at NotFoundError.NetworkError [as constructor] (/app/node_modules/stellar-sdk/src/errors.ts:17:5)
[info] at new NotFoundError (/app/node_modules/stellar-sdk/src/errors.ts:31:5)
[info] at /app/node_modules/stellar-sdk/src/call_builder.ts:413:13
[info] at step (/app/node_modules/stellar-sdk/node_modules/tslib/tslib.js:141:27)
[info] at Object.next (/app/node_modules/stellar-sdk/node_modules/tslib/tslib.js:122:57)
[info] at /app/node_modules/stellar-sdk/node_modules/tslib/tslib.js:115:75
[info] at new Promise (<anonymous>)
[info] at Object.__awaiter (/app/node_modules/stellar-sdk/node_modules/tslib/tslib.js:111:16)
[info] at CallBuilder._handleNetworkError (/app/node_modules/stellar-sdk/lib/call_builder.js:261:24)
[info] at processTicksAndRejections (node:internal/process/task_queues:95:5) {
[info] constructor: [Function: NotFoundError],
[info] response: {
[info] type: 'https://stellar.org/horizon-errors/not_found',
[info] title: 'Resource Missing',
[info] status: 404,
[info] detail: 'The resource at the url requested was not found. This usually occurs for one of two reasons: The url requested is not valid, or no data in our database could be found with the parameters provided.'
[info] } 

Change to return 404 from the server and show not found to the user as well.