Recently, I've been working on an http interceptor that was functioning smoothly until just yesterday.
It consists of static methods, and for some reason, one of them is now causing issues.
Here is the error message displayed in the console:
my.component.ts:162 Error in PUT Request TypeError: HttpInterceptorService_1.httpInterceptorService.createHttpErrorMessage is not a function
at TapSubscriber._tapNext (http-interceptor.service.ts:113)
at TapSubscriber.push../node_modules/rxjs/_esm5/internal/operators/tap.js.TapSubscriber._next (tap.js:45)
at TapSubscriber.push../node_modules/rxjs/_esm5/internal/Subscriber.js.Subscriber.next (Subscriber.js:54)
at TakeSubscriber.push../node_modules/rxjs/_esm5/internal/operators/take.js.TakeSubscriber._next (take.js:40)
at TakeSubscriber.push../node_modules/rxjs/_esm5/internal/Subscriber.js.Subscriber.next (Subscriber.js:54)
at Notification.push../node_modules/rxjs/_esm5/internal/Notification.js.Notification.observe (Notification.js:15)
at AsyncAction.push../node_modules/rxjs/_esm5/internal/operators/delay.js.DelaySubscriber.dispatch [as work] (delay.js:42)
at AsyncAction.push../node_modules/rxjs/_esm5/internal/scheduler/AsyncAction.js.AsyncAction._execute (AsyncAction.js:63)
at AsyncAction.push../node_modules/rxjs/_esm5/internal/scheduler/AsyncAction.js.AsyncAction.execute (AsyncAction.js:51)
at AsyncScheduler.push../node_modules/rxjs/_esm5/internal/scheduler/AsyncScheduler.js.AsyncScheduler.flush (AsyncScheduler.js:43)
Below is a snippet of the code from the interceptor that might be relevant to the bug:
// Excerpt from the interceptor code
@Injectable({
providedIn: 'root'
})
export class HttpInterceptorService implements HttpInterceptor {
// Other static declarations and then my httpInterceptorService
static httpInterceptorService: HttpInterceptorService;
constructor(
httpInterceptorService: HttpInterceptorService,
) {
HttpInterceptorService.httpInterceptorService = httpInterceptorService;
}
// Intercept method and other functions go here...
createHttpErrorMessage(error: HttpErrorResponse, statusText: string) {
// Function to create error message
}
handleHttpError(error: HttpErrorResponse) {
// Function to handle HTTP errors
}
}
Up until the recent error, the interceptor had been functioning correctly without any issues. Can you spot what I might be doing wrong here?