File tree Expand file tree Collapse file tree 2 files changed +12
-3
lines changed
Expand file tree Collapse file tree 2 files changed +12
-3
lines changed Original file line number Diff line number Diff line change 1- 1.3.2
1+ 1.3.3
Original file line number Diff line number Diff line change @@ -30,8 +30,17 @@ export const handler: Handlers<Data> = {
3030 // Validate credentials by hitting a protected GET
3131 try {
3232 await backendGet ( "/api/v1/invoices" , basic ) ;
33- } catch ( _e ) {
34- return ctx . render ( { error : "Invalid credentials" , username } ) ;
33+ } catch ( e ) {
34+ const errorMessage = e instanceof Error ? e . message : String ( e ) ;
35+ // Check if it's an authentication error (401/403) vs other errors
36+ if ( errorMessage . includes ( "401" ) || errorMessage . includes ( "403" ) ) {
37+ return ctx . render ( { error : "Invalid credentials" , username } ) ;
38+ } else if ( errorMessage . includes ( "500" ) || errorMessage . includes ( "502" ) || errorMessage . includes ( "503" ) || errorMessage . includes ( "504" ) ) {
39+ return ctx . render ( { error : "Server error. Please try again later." , username } ) ;
40+ } else {
41+ // Network errors, timeouts, or other connection issues
42+ return ctx . render ( { error : "Unable to connect to server. Please check your connection and try again." , username } ) ;
43+ }
3544 }
3645 const headers = new Headers ( {
3746 ...setAuthCookieHeaders ( basic ) ,
You can’t perform that action at this time.
0 commit comments