That there were certain irregularities and informalities in the proceedings of the board of mayor and aldermen in laying out Pearce Street across the railroad of the petitioner must be conceded. But the record of an inferior court or tribunal, not proceeding according to the course of the common law, cannot be impeached for mere informalities, either in an action of tort against one exercising authority under its order or decree, or by bill in equity to enjoin him from so doing. The writ of certiorari brings up the whole record, and this will not be granted on the petition of a party claiming to be injured, unless it shall be seen that substantial justice requires it. Robbins v. Lexington, 8 Cush. 292. Locke v. Lexington, 122 Mass. 290. Foley v. Haverhill, 144 Mass. 352. Attorney General v. Northampton, 143 Mass. 589.
*460Even if, in a limited sense, the error committed by such a tribunal may be said to affect its jurisdiction, as where notice of its proposed proceedings is defective, advantage of this can be taken by certiorari only. “ The rule,” it is said in- Foley v. Haverhill, ubi supra, “ seems to be somewhat analogous to another Massachusetts rule, that a domestic judgment cannot be impeached collaterally upon grounds which would be open on writ of error.” The contention of the plaintiff is, that even if, in the case at bar, a petition for certiorari might have been brought, the report shows that the mayor and aldermen had absolutely no jurisdiction of the subject with which they undertook to deal; and that, whether their order could or could not have been dealt with upon certiorari, it was wholly void, and therefore it is entitled to an injunction forbidding the defendants to act thereunder.
The mayor and aldermen of Fall River, with the concurrence of the common council, had exclusive power to lay out streets and town ways within the city limits. By the Gen. Sts. c. 63, § 59, before such a way was laid out over a railway already constructed, an application to the county commissioners was necessary, who, after proper notice, might give permission so to do, where the way was to cross above the railroad, requiring it to be laid out and constructed according to the provisions of § 62. The county commissioners were entitled also to give special authority permitting the highway to be laid out upon a level with the railroad, when in their opinion public necessity should so demand.
A petition for the location of a way over the railroad was presented to the city council, and the mayor was subsequently authorized to petition the county commissioners to lay out Pearce Street, from North Main Street to Davol Street, fifty feet wide, and “ to cross the track of the Old Colony Railroad at grade.” This petition to the county commissioners was made, and, after due proceedings, it was ordered by the county commissioners that “leave be granted to lay out Pearce Street as prayed for.” Acting under this authority, the mayor and aldermen proceeded to lay out Pearce Street across the railroad forty feet in width on the same grade, and in this laying out the common council concurred. The city entered upon the street, awarded damages *461to the abutters, worked the street, and opened it to the public up to the location of the railroad on either side. The railroad corporation never admitted the validity of the laying out across its location, refused to remove its fences from either side of the location, and in 1880 set the fences on the easterly side thereof several feet farther eastward upon the street, to a line upon land subsequently taken by authority of the Legislature to widen its location.
The inquiry that was submitted to the county commissioners by the petition of the mayor was twofold: first, whether public necessity and convenience required that there should be any way across the railroad; and, secondly, if there was to be such crossing, whether it might be ordered to be made at grade. The plaintiff contends that the width of the way stated therein is an essential part of the petition, that the leave granted by the county commissioners was only to lay out a crossing at grade of fifty feet in width, and that the attempt to lay out one of forty feet in width was a substantial departure from the leave as granted, by reason of which the subsequent proceedings would be invalidated. If we assume, without so deciding, that the construction given by the plaintiff to the authority granted by the county commissioners is correct, and that the act done by the mayor and aldermen, in concurrence with the common council, in laying out Pearce Street forty feet only in width, was unauthorized, the question remains whether there was any remedy for the plaintiff, except by a petition for certiorari. Even if the act of the city authorities was wholly without their jurisdiction and void, it is clearly settled that certiorari would be an appropriate remedy. Charlestown v. County Commissioners, 3 Met. 202. Boston & Maine Railroad v. Lawrence, 2 Allen, 107. Boston & Albany Railroad v. County Commissioners, 116 Mass. 73.
It may be questioned if the proceedings of tribunals exercising judicial functions can be impeached upon grounds which are open under a writ of certiorai’i. Barnes v. Springfield, 4 Allen, 488. Foley v. Haverhill, 144 Mass. 352. Whether this be so or not, the laying out of the street across the plaintiff’s location forty feet in width only was an act done by the board of mayor and aldermen and the common council in excess of their author*462ity, while dealing with a matter within their jurisdiction, rather than an act without jurisdiction and therefore wholly void. The office of a writ of certiorari is to correct the errors and restrain the excesses in the exercise of jurisdiction by inferior courts or officers acting judicially. Locke v. Lexington, 122 Mass. 290. It is not intended that their proceedings shall be attacked collaterally, which might often result in confusion and perhaps grave injustice, and careful provision has been made by legislation for the protection of the rights of all parties interested, when such proceedings are brought up for revision on certiorari. In such case this court, if it finds error therein, may not only quash the proceedings, but may order them to be amended, may enter such judgment as the inferior tribunal should have entered, or may direct it to proceed anew according to law. Gen. Sts. c. 145, § 9; Pub. Sts. c. 186, § 9. Boston & Albany Railroad v. County Commissioners, 116 Mass. 73.
The question of laying out a street at grade over the railroad location was a matter placed within the jurisdiction of the city authorities by the action of the county commissioners. They had received full power to locate such a street, if they determined that public convenience required it. If it was an error on their part in locating the way only forty feet in width, it was an error of detail in dealing with a subject legally confided to them. This error could have been corrected in some one of the modes adverted to. It did not require that their proceedings should be wholly set aside. The remedy of the plaintiff, therefore, was solely by a petition for certiorari.
The plaintiff also contends, that, even if the laying out was valid, or cannot be attacked in this proceeding, the defendants can have no right to enter upon its location and prepare the road for public travel across it, within the lines of the way as laid out, and alleges that the defendant city asserts the right to do this at such times and in such manner as it deems best. The plaintiff further contends, that it was the duty of the county commissioners to pass a definite order as to how, at what times, and by whom the work' should be done. It therefore urges that it is entitled to an injunction forbidding the defendant city by its servants from entering upon its location for the purpose stated. The question thus presented was not passed upon by the presid*463ing judge, and, in the view that he took as to the invalidity of the laying out, it was not necessary that it should he. It may he necessary for us to deal with it, as the whole case is reported to us to make such order or decree as, upon the consideration of all the facts, equity may require. So far as this contention is concerned with the order of the county commissioners, if there was a deficiency therein, as the plaintiff urges, it was to be remedied by a petition for certiorari, or perhaps by an application to the county commissioners themselves, on the ground that it was not sufficiently explicit. But if the defendants could have no right to enter upon the plaintiff’s location, and the permission to lay out the way across the plaintiff’s railroad involved, and could involve, no right to enter upon the location of the plaintiff’s railroad, there to prepare the way for public travel, and if the plaintiff was itself preparing its own railroad to be crossed by the highway, or was ready to do so, it may be that it would be entitled to the injunction prayed for.
As to the respective duties of the railroad company and the city authorities in the construction of a highway at grade, the case is governed by the Gen. Sts. c. 63, §§ 57-60, then in force. By § 57, the expenses of and incident to constructing and maintaining the road or way at such crossing shall he borne by the county, city, town, or corporation owning the same. The inference from this drawn by the plaintiff, that some one else is to do the work, as unless this were so it would be unnecessary to provide that the corporation liable should bear the expense, is quite too forced, especially when this section is connected with § 60, which provides that a railroad “ corporation whose road is crossed by a turnpike Or other way on a level therewith shall at its own expense so guard or protect its rails by plank, timber, or otherwise, as to secure a safe and easy passage across its road.” The railroad corporation is further required to provide for any subsequent alteration of the way, or any additional safeguards which the county commissioners may afterwards order to be established.
In Davis v. Leominster, 1 Allen, 182, 184, it was held that the obligation of a town to make roads safe and convenient for travellers continues where such roads are crossed by railroads at grade, except so far as the necessary use of the crossing by the *464railroad may prevent it, and subject to such specific directions as may be given by the county commissioners. In Jones v. Waltham, 4 Cush. 299, it was held that, if the town made the crossing safe and convenient, except so far as the construction and operation of the railroad rendered it impracticable without interfering therewith, it was not liable for an injury occurring thereon. In Seanlan v. Boston, 140 Mass. 84, which was decided under the Pub. Sts. c. 112, § 124, — which is the same in substance as the Gen. Sts. c. 63, § 60, — the railroad company had two lines of track eight feet apart. It was held that it was the duty of the railroad company to beep in repair, not only the space between the tracks, but that between the two lines of track, and that the city was not liable for an injury occurring by a defect in that part of the planking between the two lines of track.
The intention of the Legislature has been to impose upon the city, or other corporation authorized to maintain a way crossing a railroad at grade, the expense and the duty of maintaining the way up to the outer line of the railroad tracks, or so near their foundations as not to interfere with them, and upon the railroad between these outer lines. Oases may be suggested where it would not be easy to construct the way up to the outer lines of the railroad without some inconvenience to it, and by the statute the “ ways shall be so made as not to obstruct or injure the railroad,” (Gen. Sts. c. 63, § 58,) except, it must be presumed, so far as any way would necessarily have that effect. It was contemplated that, when the portion which each should construct and maintain was settled by law, and when no specific directions were given by the county commissioners, no difficulty would be experienced in constructing the entire crossing, with proper ■regard to the convenience of both the parties interested and the safety of the public. If differences did arise, and neither party sought from the county commissioners any specific directions, each was left to perform its own duty as it might, having regard to the rights of the other.
Assuming that the allegations of the bill, the order to the highway surveyor, Thurston, and the answer, are to be interpreted as showing that the defendant city proposes to enter on the location and construct the way across the whole of it, including that portion occupied by the tracks, the plaintiff is *465not entitled to an injunction forbidding it. It is its own duty to prepare the way, so far as the space between its rails is concerned, “ to secure a safe and easy passage across its road.” This duty it refuses to perform, and the performance of it could be enforced by a proceeding for an injunction initiated by the defendant city. If, instead of commencing such a proceeding, the defendant city now proposes itself to do this work, whatever the inconvenience to the plaintiff may be, it has no right to ask that the defendants be restrained from doing it in any suitable and appropriate manner.
Bill dismissed.