(errorCode: ErrorCode)
| 74 | } |
| 75 | |
| 76 | export function getMessageByErrorCode(errorCode: ErrorCode): string { |
| 77 | if (errorCode.includes('database')) { |
| 78 | return 'An error occurred while executing a database query.'; |
| 79 | } |
| 80 | |
| 81 | switch (errorCode) { |
| 82 | case 'bad_request:api': |
| 83 | return "The request couldn't be processed. Please check your input and try again."; |
| 84 | |
| 85 | case 'unauthorized:auth': |
| 86 | return 'You need to sign in before continuing.'; |
| 87 | case 'forbidden:auth': |
| 88 | return 'Your account does not have access to this feature.'; |
| 89 | |
| 90 | case 'rate_limit:chat': |
| 91 | return 'You have exceeded your maximum number of messages for the day. Please try again later.'; |
| 92 | case 'not_found:chat': |
| 93 | return 'The requested chat was not found. Please check the chat ID and try again.'; |
| 94 | case 'forbidden:chat': |
| 95 | return 'This chat belongs to another user. Please check the chat ID and try again.'; |
| 96 | case 'unauthorized:chat': |
| 97 | return 'You need to sign in to view this chat. Please sign in and try again.'; |
| 98 | case 'offline:chat': |
| 99 | return "We're having trouble sending your message. Please check your internet connection and try again."; |
| 100 | |
| 101 | case 'not_found:document': |
| 102 | return 'The requested document was not found. Please check the document ID and try again.'; |
| 103 | case 'forbidden:document': |
| 104 | return 'This document belongs to another user. Please check the document ID and try again.'; |
| 105 | case 'unauthorized:document': |
| 106 | return 'You need to sign in to view this document. Please sign in and try again.'; |
| 107 | case 'bad_request:document': |
| 108 | return 'The request to create or update the document was invalid. Please check your input and try again.'; |
| 109 | |
| 110 | default: |
| 111 | return 'Something went wrong. Please try again later.'; |
| 112 | } |
| 113 | } |
| 114 | |
| 115 | function getStatusCodeByType(type: ErrorType) { |
| 116 | switch (type) { |
no outgoing calls
no test coverage detected
searching dependent graphs…