83176f53b0
* Regression tests for the messaging mode on sendSms() * Let sendSms() name the esm_class messaging mode * Document the messaging mode option and the decision behind it * Name the constants move for migrating consumers and share the refusal's value naming * Cover the messaging-mode refusals through submitSms() * Refuse transaction mode and a report under datagram mode on sendSms() * Narrow the mode checker and name the default mode once
16 lines
585 B
TypeScript
16 lines
585 B
TypeScript
/** Whatever was thrown or rejected, as an Error. `String()` throws on some values; this cannot. */
|
|
export function errorFrom(reason: unknown): Error {
|
|
if (reason instanceof Error) return reason;
|
|
|
|
try {
|
|
return new Error(String(reason));
|
|
} catch {
|
|
return new Error('A thrown value that cannot be converted to a string');
|
|
}
|
|
}
|
|
|
|
/** String() throws on a null-prototype object or a symbol, so only a string or number is printed. */
|
|
export function namedValue(value: unknown): string {
|
|
return typeof value === 'string' || typeof value === 'number' ? String(value) : typeof value;
|
|
}
|