Releases: belgattitude/http-exception
@belgattitude/http-exception@1.5.0
Minor Changes
-
#204
c128653
Thanks @belgattitude! - Package moved to @httpx/exception.⚠️ Version 1.5.0 will be the last one ! We've moved to https://github.com/belgattitude/httpx⚠️ No breaking changes, just update from
@belgattitude/http-exception
to@httpx/exception
.The change to
httpx
namespace makes it shorter, allow more
packages to be grouped and eventually will be managed inside a github org.
@belgattitude/http-exception@1.4.0
Minor Changes
- #141
57574ed
Thanks @belgattitude! - Upgrapde to rollup v3
@belgattitude/http-exception@1.3.4
Patch Changes
- #118
2bea0d6
Thanks @belgattitude! - Bundle with rollup v3.0.0
@belgattitude/http-exception@1.3.3
Patch Changes
- #96
5b964fd
Thanks @belgattitude! - Disable minification to allow patching (patch-package...)
@belgattitude/http-exception@1.3.2
Patch Changes
- #91
9498cb2
Thanks @belgattitude! - Remove hardcoded string in supportsCause function
@belgattitude/http-exception@1.3.1
Patch Changes
- #87
a8fbdd2
Thanks @belgattitude! - Fix potential issue with cause that could be undefined
@belgattitude/http-exception@1.3.0
Minor Changes
-
#75
89d2dd8
Thanks @belgattitude! - Addedmethod
,code
anderrorId
params.Name Type Description url string?
url on which the error happened method string?
http method used to load the url code string?
Custom code (ie: 'AbortError', 'E-1234'...) errorId string?
Unique error identifier (ie: uuid, nanoid...) const err = new HttpRequestTimeout({ url: 'https://api.dev/user/belgattitude', method: 'GET', code: 'NETWORK_FAILURE', errorId: nanoid(), // can be shared by frontend/backend }); console.log(err.url, err.method, err.code, err.errorId);
Patch Changes
- #71
f3c423f
Thanks @belgattitude! - Improved documenation and website live
@belgattitude/http-exception@1.2.0
Minor Changes
-
#67
7208e7b
Thanks @belgattitude! - Export convertToSerializable and createFromSerializableimport { convertToSerializable, createFromSerializable, } from '@belgattitude/http-exception/serializer'; const serializableObject = convertToSerializable(new HttpForbidden()); const exception = createFromSerializable(serializableObject);
Patch Changes
- #56
bddd84a
Thanks @belgattitude! - Initial documentation and updated examples
@belgattitude/http-exception@1.1.0
Minor Changes
-
#33
67be0fb
Thanks @belgattitude! - Add HttpException json serializer.Two new methods
fromJson
andtoJson
exported from@belgattitude/http-exception/serializer
.HttpException can be serialized to json and vice-versa. It can be useful in ssr frameworks such as
nextjs whenever a server error should be shared within the browser context (see also
the excellent superjson).Serialization supports the Error.cause
but totally ignores it the runtime (node or browser) does not support it (or without polyfills).Additionally, you can pass any native errors (
Error
,EvalError
,RangeError
,ReferenceError
,SyntaxError
,TypeError
,URIError
)
as well as a custom one (the later will be transformed to the base type Error). That was necessary to support the cause param.Method toJson(HttpException | NativeError | Error): string fromJson(string): HttpException | NativeError | Error import { HttpForbidden, HttpUnavailableForLegalReasons, } from '@belgattitude/http-exception'; import { fromJson, toJson } from '@belgattitude/http-exception/serializer'; const e = new HttpForbidden({ url: 'https://www.cool.me', /* cause: new HttpUnavailableForLegalReasons({ cause: new Error('example with cause') }), */ }); const json = toJson(e); const exception = fromJson(json); // e === exception
@belgattitude/http-exception@1.0.2
Patch Changes
-
#51
421b36d
Thanks @belgattitude! - FixError.cause
on node < 16.9 and browsers that don't support for it.- Browser currently 89% support: caniuse#error.cause - (89% supports it as of sept 2022)
- Node from 16.9.0 as per mdn.
The strategy used can be summarized as:
If the browser or the node runtime does not support Error.cause parameter in the
constructor, it will simply be discarded.
ie:const err = new HttpNotFound({cause: new Error()}); console.log(err.cause) -> undefined if no support console.log(err.cause) -> Error cause if supported
To enable older browser or previous node versions, there's 2 polyfills that should
do the job