Fix RecurringError::toString

Summary: RecurringError::toString wasn't including the message. Fixed.

Reviewed By: passy

Differential Revision: D13732258

fbshipit-source-id: 71f5edef19de4e59d1c6c5bd549822871e36ede4
This commit is contained in:
John Knox
2019-01-18 08:24:38 -08:00
committed by Facebook Github Bot
parent 82f4d4ad95
commit dfe956ab39
2 changed files with 19 additions and 0 deletions

View File

@@ -0,0 +1,16 @@
/**
* Copyright 2018-present Facebook.
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
* @format
*/
import {RecurringError} from '../errors';
test('Check RecurringError toString output', () => {
const error = new RecurringError('something');
expect(error.toString()).toBe('[RecurringError] something');
/* $FlowFixMe intentionally coercing it to a string to make sure the correct
method is overridden */
expect('' + error).toBe('[RecurringError] something');
});

View File

@@ -11,4 +11,7 @@ export class RecurringError extends Error {
super(message);
this.name = 'RecurringError';
}
toString(): string {
return `[${this.name}] ${this.message}`;
}
}