bufrw
Advanced tools
Comparing version 0.9.26 to 0.9.27
@@ -65,8 +65,14 @@ // Copyright (c) 2015 Uber Technologies, Inc. | ||
module.exports.InvalidSwitchValue = TypedError({ | ||
type: 'bufrw.invalid-switch-value', | ||
message: 'invalid switch value {value}', | ||
module.exports.ReadInvalidSwitchValue = TypedError({ | ||
type: 'bufrw.read.invalid-switch-value', | ||
message: 'read invalid switch value {value}', | ||
value: null | ||
}); | ||
module.exports.WriteInvalidSwitchValue = TypedError({ | ||
type: 'bufrw.write.invalid-switch-value', | ||
message: 'write invalid switch value {value}', | ||
value: null | ||
}); | ||
module.exports.MissingStructField = TypedError({ | ||
@@ -132,1 +138,30 @@ type: 'bufrw.missing.struct-field', | ||
}); | ||
module.exports.classify = classify; | ||
function classify(err) { | ||
switch (err.type) { | ||
case 'bufrw.broken-reader-state': | ||
case 'bufrw.unstable-rw': | ||
return 'Internal'; | ||
case 'bufrw.invalid-argument': | ||
case 'bufrw.read.invalid-switch-value': | ||
case 'bufrw.short-buffer': | ||
case 'bufrw.short-read': | ||
case 'bufrw.truncated-read': | ||
case 'bufrw.zero-length-chunk': | ||
return 'Read'; | ||
case 'bufrw.fixed-length-mismatch': | ||
case 'bufrw.missing.struct-field': | ||
case 'bufrw.range-error': | ||
case 'bufrw.short-write': | ||
case 'bufrw.write.invalid-switch-value': | ||
return 'Write'; | ||
// istanbul ignore next | ||
default: | ||
return null; | ||
} | ||
} |
{ | ||
"name": "bufrw", | ||
"version": "0.9.26", | ||
"version": "0.9.27", | ||
"description": "Buffer Reading and Writing", | ||
@@ -5,0 +5,0 @@ "keywords": [], |
@@ -57,3 +57,3 @@ // Copyright (c) 2015 Uber Technologies, Inc. | ||
if (datarw === undefined) { | ||
return LengthResult.error(errors.InvalidSwitchValue({ | ||
return LengthResult.error(errors.WriteInvalidSwitchValue({ | ||
value: val | ||
@@ -75,3 +75,3 @@ })); | ||
if (datarw === undefined) { | ||
return WriteResult.error(errors.InvalidSwitchValue({ | ||
return WriteResult.error(errors.WriteInvalidSwitchValue({ | ||
value: val | ||
@@ -94,3 +94,3 @@ }), offset); | ||
if (datarw === undefined) { | ||
return ReadResult.error(errors.InvalidSwitchValue({ | ||
return ReadResult.error(errors.ReadInvalidSwitchValue({ | ||
value: val | ||
@@ -116,3 +116,3 @@ }), offset); | ||
if (datarw === undefined) { | ||
return ReadResult.error(errors.InvalidSwitchValue({ | ||
return ReadResult.error(errors.ReadInvalidSwitchValue({ | ||
value: val | ||
@@ -119,0 +119,0 @@ }), offset); |
@@ -23,2 +23,3 @@ // Copyright (c) 2015 Uber Technologies, Inc. | ||
require('./errors'); | ||
require('./interface'); | ||
@@ -25,0 +26,0 @@ require('./atoms'); |
@@ -61,4 +61,4 @@ // Copyright (c) 2015 Uber Technologies, Inc. | ||
error: { | ||
type: 'bufrw.invalid-switch-value', | ||
message: 'invalid switch value 42', | ||
type: 'bufrw.write.invalid-switch-value', | ||
message: 'write invalid switch value 42', | ||
value: 42 | ||
@@ -71,4 +71,4 @@ } | ||
error: { | ||
type: 'bufrw.invalid-switch-value', | ||
message: 'invalid switch value 42', | ||
type: 'bufrw.write.invalid-switch-value', | ||
message: 'write invalid switch value 42', | ||
value: 42 | ||
@@ -80,4 +80,4 @@ } | ||
error: { | ||
type: 'bufrw.invalid-switch-value', | ||
message: 'invalid switch value 42', | ||
type: 'bufrw.read.invalid-switch-value', | ||
message: 'read invalid switch value 42', | ||
value: 42 | ||
@@ -84,0 +84,0 @@ } |
176610
55
4437