Skip to content

Trying to overcome the lack of type annotations in catch clauses

License

Notifications You must be signed in to change notification settings

jorisvaesen/ts-error-handling

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Small example

import {ErrorHandlerQueue} from "./ErrorHandlerQueue";
import {AxiosErrorHandler} from "./AxiosErrorHandler";
import {StringErrorHandler} from "./StringErrorHandler";

try {
    // code that can throw exceptions
} catch (error: unknown) {
    ErrorHandlerQueue.create()
        .add(new AxiosErrorHandler((error: any) => {
            console.error(AxiosErrorHandler.getMessageFromError(error as AxiosError));
        }))
        .add(StringErrorHandler.createWithDefaultBehavior())
        .catch(error, true);
}

Discussion started here: https://phpc.social/@jorisvaesen/110787343759497768

About

Trying to overcome the lack of type annotations in catch clauses

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published