import { GenericStoragesError } from "@staticdeploy/core" ; import { isFunction , keys } from "lodash" ; function withErrorsConverter ( method ) { return function errorsConverter ( this ) { try { return method . apply ( this , arguments ) ; } catch ( err ) { throw new GenericStoragesError ( err ) ; } } ; } export default function convertErrors ( constructor ) { keys ( constructor . prototype ) . forEach ( ( key ) => { const method = constructor . prototype [ key ] ; if ( isFunction ( method ) ) { constructor . prototype [ key ] = withErrorsConverter ( method ) ; } } ) ; }